Skip to content

Commit d934e59

Browse files
committed
update to latest version: v1.4.1
1 parent a5255ff commit d934e59

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
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-27
4+
5+
* Support certificate verification bypass using environment variable
6+
37
## 1.4.0 - 2024-08-21
48

59
* Support digest calculation bypass

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,9 @@ The communication channel between the client program or SDK and the Trend Vision
464464
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.
465465
466466
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.
467+
468+
## Disabling certificate verification
469+
470+
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.
471+
472+
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

grpc.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const (
3737
_envvarAuthKeyNotRequired = "TM_AM_AUTH_KEY_NOT_REQUIRED" // Set to 1 and Client SDK will not send auth key to server; set to 0 or leave empty to disable.
3838
_envvarServerAddr = "TM_AM_SERVER_ADDR" // <host FQDN>:<port no>
3939
_envvarDisableTLS = "TM_AM_DISABLE_TLS" // Set to 1 to not use TLS for client-server communication; set to 0 or leave empty otherwise.
40+
_envvarDisableCertVerify = "TM_AM_DISABLE_CERT_VERIFY" // Set to 1 to disable server certificate check by client; set to 0 or leave empty to verify certificate.
4041
_envInitWindowSize = "TM_AM_WINDOW_SIZE"
4142

4243
appNameHTTPHeader = "tm-app-name"
@@ -229,6 +230,7 @@ type AmaasClient struct {
229230
addr string
230231
useTLS bool
231232
caCert string
233+
verifyCert bool
232234
timeoutSecs int
233235
appName string
234236
archHandler AmaasClientArchiveHandler
@@ -461,8 +463,8 @@ func (ac *AmaasClient) fileScanRunNormalFile(fileName string, tags []string) (st
461463
}
462464

463465
// Function to load TLS credentials with optional certificate verification
464-
func loadTLSCredentials(caCertPath string) (credentials.TransportCredentials, error) {
465-
logMsg(LogLevelDebug, "log TLS certificate = %s", caCertPath)
466+
func loadTLSCredentials(caCertPath string, verifyCert bool) (credentials.TransportCredentials, error) {
467+
logMsg(LogLevelDebug, "log TLS certificate = %s cert verify = %t", caCertPath, verifyCert)
466468
// Load the CA certificate
467469
pemServerCA, err := os.ReadFile(caCertPath)
468470
if err != nil {
@@ -477,7 +479,8 @@ func loadTLSCredentials(caCertPath string) (credentials.TransportCredentials, er
477479

478480
// Create the TLS credentials with optional verification
479481
creds := credentials.NewTLS(&tls.Config{
480-
RootCAs: certPool,
482+
InsecureSkipVerify: !verifyCert,
483+
RootCAs: certPool,
481484
})
482485

483486
return creds, nil
@@ -512,14 +515,14 @@ func (ac *AmaasClient) setupComm() error {
512515
var creds credentials.TransportCredentials
513516
if ac.caCert != "" {
514517
// Bring Your Own Certificate case
515-
creds, err = loadTLSCredentials(ac.caCert)
518+
creds, err = loadTLSCredentials(ac.caCert, ac.verifyCert)
516519
if err != nil {
517520
return err
518521
}
519522
} else {
520523
// Default SSL credentials case
521-
logMsg(LogLevelDebug, "using default SSL credential")
522-
creds = credentials.NewTLS(&tls.Config{})
524+
logMsg(LogLevelDebug, "using default SSL credential with cert verify = %t", ac.verifyCert)
525+
creds = credentials.NewTLS(&tls.Config{InsecureSkipVerify: !ac.verifyCert})
523526
}
524527

525528
if enableProxy {
@@ -703,10 +706,11 @@ func identifyServerAddr(region string) (string, error) {
703706
return fmt.Sprintf("%s:%d", fqdn, _defaultCommPort), nil
704707
}
705708

706-
func retrieveTLSSettings() (useTLS bool) {
709+
func retrieveTLSSettings() (useTLS bool, verifyCert bool) {
707710
envDisableTLS := os.Getenv(_envvarDisableTLS)
711+
envDisableCertVerify := os.Getenv(_envvarDisableCertVerify)
708712

709-
return (envDisableTLS == "" || envDisableTLS == "0")
713+
return (envDisableTLS == "" || envDisableTLS == "0"), envDisableCertVerify != "1"
710714
}
711715

712716
func getDefaultScanTimeout() (int, error) {
@@ -1032,6 +1036,8 @@ func NewClientInternal(key string, addr string, useTLS bool, caCert string) (*Am
10321036

10331037
var err error
10341038

1039+
ac.useTLS, ac.verifyCert = retrieveTLSSettings()
1040+
10351041
if ac.timeoutSecs, err = getDefaultScanTimeout(); err != nil {
10361042
return nil, err
10371043
}

grpc_client_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,22 +218,28 @@ func TestIdServerAddressValidWithOverride(t *testing.T) {
218218
func TestRetrieveTLSSettings(t *testing.T) {
219219

220220
os.Setenv(_envvarDisableTLS, "")
221+
os.Setenv(_envvarDisableCertVerify, "")
221222

222-
useTLS := retrieveTLSSettings()
223+
useTLS, verifyCert := retrieveTLSSettings()
223224

224225
assert.Equal(t, true, useTLS)
226+
assert.Equal(t, true, verifyCert)
225227

226228
os.Setenv(_envvarDisableTLS, "0")
229+
os.Setenv(_envvarDisableCertVerify, "0")
227230

228-
useTLS = retrieveTLSSettings()
231+
useTLS, verifyCert = retrieveTLSSettings()
229232

230233
assert.Equal(t, true, useTLS)
234+
assert.Equal(t, true, verifyCert)
231235

232236
os.Setenv(_envvarDisableTLS, "1")
237+
os.Setenv(_envvarDisableCertVerify, "1")
233238

234-
useTLS = retrieveTLSSettings()
239+
useTLS, verifyCert = retrieveTLSSettings()
235240

236241
assert.Equal(t, false, useTLS)
242+
assert.Equal(t, false, verifyCert)
237243
}
238244

239245
//

sdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func NewClient(key string, region string) (c *AmaasClient, e error) {
4343
return nil, err
4444
}
4545

46-
ac.useTLS = retrieveTLSSettings()
46+
ac.useTLS, ac.verifyCert = retrieveTLSSettings()
4747

4848
if ac.timeoutSecs, err = getDefaultScanTimeout(); err != nil {
4949
return nil, err

0 commit comments

Comments
 (0)