Skip to content

Commit f571828

Browse files
su-amaasliangsengk-tm
authored andcommitted
update to latest version: v1.4.1
1 parent e3815e8 commit f571828

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 1.4.1 - 2024-08-28
4+
5+
* Support certificate verification bypass using environment variable
6+
37
## 1.4.0 - 2024-08-23
48

59
* Update README.md

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,9 @@ The communication channel between the client program or SDK and the Trend Vision
354354
The certificate employed by server-side TLS is a publicly-signed certificate from Trend Micro Inc, issued by a trusted Certificate Authority (CA), further bolstering security measures.
355355

356356
The File Security SDK consistently adopts TLS as the default communication channel, prioritizing security at all times. It is strongly advised not to disable TLS in a production environment while utilizing the File Security SDK, as doing so could compromise the integrity and confidentiality of transmitted data.
357+
358+
## Disabling certificate verification
359+
360+
For customers who need to enable TLS channel encryption without verifying the provided CA certificate, the `TM_AM_DISABLE_CERT_VERIFY` environment variable can be set. However, this option is only recommended for use in testing environments.
361+
362+
When `TM_AM_DISABLE_CERT_VERIFY` is set to `1`, certificate verification is disabled. By default, the certificate will be verified.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0
1+
1.4.1

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.trend</groupId>
77
<artifactId>file-security-java-sdk</artifactId>
8-
<version>1.4.0</version>
8+
<version>1.4.1</version>
99

1010
<name>file-security-java-sdk</name>
1111
<url>https://github.com/trendmicro/tm-v1-fs-java-sdk</url>

src/main/java/com/trend/cloudone/amaas/AMaasClient.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import io.grpc.stub.StreamObserver;
1717
import io.grpc.stub.CallStreamObserver;
1818
import io.grpc.StatusRuntimeException;
19+
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
20+
import io.netty.handler.ssl.SslContext;
1921
import com.google.protobuf.ByteString;
2022
import com.trend.cloudone.amaas.scan.ScanGrpc;
2123
import com.trend.cloudone.amaas.scan.ScanOuterClass;
@@ -84,27 +86,34 @@ public AMaasClient(final String region, final String host, final String apiKey,
8486
}
8587
if (enabledTLS) {
8688
log(Level.FINE, "Using prod grpc service {0}", target);
87-
if (caCertPath != null && !caCertPath.isEmpty()) {
88-
// Bring Your Own Certificate case
89-
try {
90-
File certFile = Paths.get(caCertPath).toFile();
91-
this.channel = NettyChannelBuilder.forTarget(target)
92-
.sslContext(GrpcSslContexts.forClient().trustManager(certFile).build())
93-
.build();
94-
} catch (SSLException | UnsupportedOperationException e) {
95-
throw new AMaasException(AMaasErrorCode.MSG_ID_ERR_LOAD_SSL_CERT);
96-
}
97-
} else {
98-
// Default SSL credentials case
99-
try {
100-
log(Level.FINE, "Using prod grpc service {0}", target);
101-
this.channel = NettyChannelBuilder.forTarget(target)
102-
.sslContext(GrpcSslContexts.forClient().build())
103-
.build();
104-
} catch (SSLException e) {
105-
throw new AMaasException(AMaasErrorCode.MSG_ID_ERR_LOAD_SSL_CERT);
89+
String verifyCertEnv = System.getenv("TM_AM_DISABLE_CERT_VERIFY");
90+
boolean verifyCert = !("1".equals(verifyCertEnv));
91+
SslContext context;
92+
93+
try {
94+
if (!verifyCert) {
95+
// Bypassing certificate verification
96+
log(Level.FINE, "Bypassing certificate verification");
97+
context = GrpcSslContexts.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
98+
} else {
99+
if (caCertPath != null && !caCertPath.isEmpty()) {
100+
// Bring Your Own Certificate case
101+
log(Level.FINE, "Using certificate {0}", caCertPath);
102+
File certFile = Paths.get(caCertPath).toFile();
103+
context = GrpcSslContexts.forClient().trustManager(certFile).build();
104+
} else {
105+
// Default SSL credentials case
106+
log(Level.FINE, "Using default certificate");
107+
context = GrpcSslContexts.forClient().build();
108+
}
106109
}
110+
} catch (SSLException | UnsupportedOperationException e) {
111+
throw new AMaasException(AMaasErrorCode.MSG_ID_ERR_LOAD_SSL_CERT);
107112
}
113+
114+
this.channel = NettyChannelBuilder.forTarget(target)
115+
.sslContext(context)
116+
.build();
108117
} else {
109118
log(Level.FINE, "Using grpc service with TLS disenabled {0}", target);
110119
this.channel = NettyChannelBuilder.forTarget(target)

0 commit comments

Comments
 (0)