@@ -1444,6 +1444,10 @@ func TestClientSideEncryptionProse(t *testing.T) {
14441444 if os .Getenv ("KMS_MOCK_SERVERS_RUNNING" ) == "" {
14451445 mt .Skipf ("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set" )
14461446 }
1447+ if tlsCAFileKMIP == "" || tlsClientCertificateKeyFileKMIP == "" {
1448+ mt .Fatal ("Env vars CSFLE_TLS_CA_FILE and CSFLE_TLS_CLIENT_CERT_FILE must be set" )
1449+ }
1450+
14471451 validKmsProviders := map [string ]map [string ]interface {}{
14481452 "aws" : {
14491453 "accessKeyId" : awsAccessKeyID ,
@@ -1513,50 +1517,50 @@ func TestClientSideEncryptionProse(t *testing.T) {
15131517 SetKeyVaultNamespace (kvNamespace )
15141518
15151519 // make TLS opts containing client certificate and CA file
1516- tlsConfig := make (map [string ]* tls.Config )
1517- if tlsCAFileKMIP != "" && tlsClientCertificateKeyFileKMIP != "" {
1518- clientAndCATlsMap := map [string ]interface {}{
1519- "tlsCertificateKeyFile" : tlsClientCertificateKeyFileKMIP ,
1520- "tlsCAFile" : tlsCAFileKMIP ,
1521- }
1522- certConfig , err := options .BuildTLSConfig (clientAndCATlsMap )
1523- assert .Nil (mt , err , "BuildTLSConfig error: %v" , err )
1524- tlsConfig ["aws" ] = certConfig
1525- tlsConfig ["azure" ] = certConfig
1526- tlsConfig ["gcp" ] = certConfig
1527- tlsConfig ["kmip" ] = certConfig
1528- }
1520+ clientAndCATLSConfig , err := options .BuildTLSConfig (map [string ]interface {}{
1521+ "tlsCertificateKeyFile" : tlsClientCertificateKeyFileKMIP ,
1522+ "tlsCAFile" : tlsCAFileKMIP ,
1523+ })
1524+ assert .Nil (mt , err , "BuildTLSConfig error: %v" , err )
15291525
15301526 // create valid Client Encryption options and set valid TLS options
15311527 validClientEncryptionOptionsWithTLS := options .ClientEncryption ().
15321528 SetKmsProviders (validKmsProviders ).
15331529 SetKeyVaultNamespace (kvNamespace ).
1534- SetTLSConfig (tlsConfig )
1530+ SetTLSConfig (map [string ]* tls.Config {
1531+ "aws" : clientAndCATLSConfig ,
1532+ "azure" : clientAndCATLSConfig ,
1533+ "gcp" : clientAndCATLSConfig ,
1534+ "kmip" : clientAndCATLSConfig ,
1535+ })
15351536
15361537 // make TLS opts containing only CA file
1537- if tlsCAFileKMIP != "" {
1538- caTlsMap := map [string ]interface {}{
1539- "tlsCAFile" : tlsCAFileKMIP ,
1540- }
1541- certConfig , err := options .BuildTLSConfig (caTlsMap )
1542- assert .Nil (mt , err , "BuildTLSConfig error: %v" , err )
1543- tlsConfig ["aws" ] = certConfig
1544- tlsConfig ["azure" ] = certConfig
1545- tlsConfig ["gcp" ] = certConfig
1546- tlsConfig ["kmip" ] = certConfig
1547- }
1538+ caTLSConfig , err := options .BuildTLSConfig (map [string ]interface {}{
1539+ "tlsCAFile" : tlsCAFileKMIP ,
1540+ })
1541+ assert .Nil (mt , err , "BuildTLSConfig error: %v" , err )
15481542
15491543 // create invalid Client Encryption options with expired credentials
15501544 expiredClientEncryptionOptions := options .ClientEncryption ().
15511545 SetKmsProviders (expiredKmsProviders ).
15521546 SetKeyVaultNamespace (kvNamespace ).
1553- SetTLSConfig (tlsConfig )
1547+ SetTLSConfig (map [string ]* tls.Config {
1548+ "aws" : caTLSConfig ,
1549+ "azure" : caTLSConfig ,
1550+ "gcp" : caTLSConfig ,
1551+ "kmip" : caTLSConfig ,
1552+ })
15541553
15551554 // create invalid Client Encryption options with invalid hostnames
15561555 invalidHostnameClientEncryptionOptions := options .ClientEncryption ().
15571556 SetKmsProviders (invalidKmsProviders ).
15581557 SetKeyVaultNamespace (kvNamespace ).
1559- SetTLSConfig (tlsConfig )
1558+ SetTLSConfig (map [string ]* tls.Config {
1559+ "aws" : caTLSConfig ,
1560+ "azure" : caTLSConfig ,
1561+ "gcp" : caTLSConfig ,
1562+ "kmip" : caTLSConfig ,
1563+ })
15601564
15611565 awsMasterKeyNoClientCert := map [string ]interface {}{
15621566 "region" : "us-east-1" ,
@@ -1622,7 +1626,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
16221626
16231627 possibleErrors := []string {
16241628 "x509: certificate signed by unknown authority" , // Windows
1625- "x509: “valid.testing.golang.invalid” certificate is not trusted" , // MacOS
1629+ "x509: “valid.testing.golang.invalid” certificate is not trusted" , // macOS
1630+ "x509: “server” certificate is not standards compliant" , // macOS
16261631 "x509: certificate is not authorized to sign other certificates" , // All others
16271632 }
16281633
0 commit comments