Skip to content

Commit

Permalink
update to latest version: v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
su-amaas authored and liangsengk-tm committed Aug 28, 2024
1 parent e3815e8 commit f571828
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.4.1 - 2024-08-28

* Support certificate verification bypass using environment variable

## 1.4.0 - 2024-08-23

* Update README.md
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,9 @@ The communication channel between the client program or SDK and the Trend Vision
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.

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.

## Disabling certificate verification

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.

When `TM_AM_DISABLE_CERT_VERIFY` is set to `1`, certificate verification is disabled. By default, the certificate will be verified.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0
1.4.1
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.trend</groupId>
<artifactId>file-security-java-sdk</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>

<name>file-security-java-sdk</name>
<url>https://github.com/trendmicro/tm-v1-fs-java-sdk</url>
Expand Down
47 changes: 28 additions & 19 deletions src/main/java/com/trend/cloudone/amaas/AMaasClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import io.grpc.stub.StreamObserver;
import io.grpc.stub.CallStreamObserver;
import io.grpc.StatusRuntimeException;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.handler.ssl.SslContext;
import com.google.protobuf.ByteString;
import com.trend.cloudone.amaas.scan.ScanGrpc;
import com.trend.cloudone.amaas.scan.ScanOuterClass;
Expand Down Expand Up @@ -84,27 +86,34 @@ public AMaasClient(final String region, final String host, final String apiKey,
}
if (enabledTLS) {
log(Level.FINE, "Using prod grpc service {0}", target);
if (caCertPath != null && !caCertPath.isEmpty()) {
// Bring Your Own Certificate case
try {
File certFile = Paths.get(caCertPath).toFile();
this.channel = NettyChannelBuilder.forTarget(target)
.sslContext(GrpcSslContexts.forClient().trustManager(certFile).build())
.build();
} catch (SSLException | UnsupportedOperationException e) {
throw new AMaasException(AMaasErrorCode.MSG_ID_ERR_LOAD_SSL_CERT);
}
} else {
// Default SSL credentials case
try {
log(Level.FINE, "Using prod grpc service {0}", target);
this.channel = NettyChannelBuilder.forTarget(target)
.sslContext(GrpcSslContexts.forClient().build())
.build();
} catch (SSLException e) {
throw new AMaasException(AMaasErrorCode.MSG_ID_ERR_LOAD_SSL_CERT);
String verifyCertEnv = System.getenv("TM_AM_DISABLE_CERT_VERIFY");
boolean verifyCert = !("1".equals(verifyCertEnv));
SslContext context;

try {
if (!verifyCert) {
// Bypassing certificate verification
log(Level.FINE, "Bypassing certificate verification");
context = GrpcSslContexts.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
} else {
if (caCertPath != null && !caCertPath.isEmpty()) {
// Bring Your Own Certificate case
log(Level.FINE, "Using certificate {0}", caCertPath);
File certFile = Paths.get(caCertPath).toFile();
context = GrpcSslContexts.forClient().trustManager(certFile).build();
} else {
// Default SSL credentials case
log(Level.FINE, "Using default certificate");
context = GrpcSslContexts.forClient().build();
}
}
} catch (SSLException | UnsupportedOperationException e) {
throw new AMaasException(AMaasErrorCode.MSG_ID_ERR_LOAD_SSL_CERT);
}

this.channel = NettyChannelBuilder.forTarget(target)
.sslContext(context)
.build();
} else {
log(Level.FINE, "Using grpc service with TLS disenabled {0}", target);
this.channel = NettyChannelBuilder.forTarget(target)
Expand Down

0 comments on commit f571828

Please sign in to comment.