Skip to content

Commit 4f8c615

Browse files
committed
Adding SSL to grpc connections for agents and collectors. (using collector client 2.0.1 for collectors)
1 parent 340141e commit 4f8c615

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

backend/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@
326326
<dependency>
327327
<groupId>com.utmstack.grpc.jclient</groupId>
328328
<artifactId>collector-client-4j</artifactId>
329-
<version>1.2.5</version>
329+
<version>2.0.1</version>
330330
</dependency>
331331

332332
<!-- WebSocket dependency -->

backend/src/main/java/com/park/utmstack/config/GrpcConfiguration.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
import com.park.utmstack.security.GrpcInterceptor;
44
import io.grpc.ManagedChannel;
5-
import io.grpc.ManagedChannelBuilder;
5+
import io.grpc.netty.GrpcSslContexts;
6+
import io.grpc.netty.NettyChannelBuilder;
7+
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
68
import org.springframework.beans.factory.annotation.Value;
79
import org.springframework.context.annotation.Bean;
810
import org.springframework.context.annotation.Configuration;
911

1012
import javax.annotation.PreDestroy;
13+
import javax.net.ssl.SSLException;
1114

1215
@Configuration
1316
public class GrpcConfiguration {
@@ -20,11 +23,10 @@ public class GrpcConfiguration {
2023
private Integer serverPort;
2124

2225
@Bean
23-
public ManagedChannel managedChannel() {
24-
this.channel = ManagedChannelBuilder.forAddress(serverAddress, serverPort)
26+
public ManagedChannel managedChannel() throws SSLException {
27+
this.channel = NettyChannelBuilder.forAddress(serverAddress, serverPort)
2528
.intercept(new GrpcInterceptor())
26-
.usePlaintext()
27-
.enableRetry()
29+
.sslContext(GrpcSslContexts.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build())
2830
.build();
2931
return this.channel;
3032
}

0 commit comments

Comments
 (0)