@@ -1444,6 +1444,10 @@ func TestClientSideEncryptionProse(t *testing.T) {
1444
1444
if os .Getenv ("KMS_MOCK_SERVERS_RUNNING" ) == "" {
1445
1445
mt .Skipf ("Skipping test as KMS_MOCK_SERVERS_RUNNING is not set" )
1446
1446
}
1447
+ if tlsCAFileKMIP == "" || tlsClientCertificateKeyFileKMIP == "" {
1448
+ mt .Fatal ("Env vars CSFLE_TLS_CA_FILE and CSFLE_TLS_CLIENT_CERT_FILE must be set" )
1449
+ }
1450
+
1447
1451
validKmsProviders := map [string ]map [string ]interface {}{
1448
1452
"aws" : {
1449
1453
"accessKeyId" : awsAccessKeyID ,
@@ -1513,50 +1517,50 @@ func TestClientSideEncryptionProse(t *testing.T) {
1513
1517
SetKeyVaultNamespace (kvNamespace )
1514
1518
1515
1519
// 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 )
1529
1525
1530
1526
// create valid Client Encryption options and set valid TLS options
1531
1527
validClientEncryptionOptionsWithTLS := options .ClientEncryption ().
1532
1528
SetKmsProviders (validKmsProviders ).
1533
1529
SetKeyVaultNamespace (kvNamespace ).
1534
- SetTLSConfig (tlsConfig )
1530
+ SetTLSConfig (map [string ]* tls.Config {
1531
+ "aws" : clientAndCATLSConfig ,
1532
+ "azure" : clientAndCATLSConfig ,
1533
+ "gcp" : clientAndCATLSConfig ,
1534
+ "kmip" : clientAndCATLSConfig ,
1535
+ })
1535
1536
1536
1537
// 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 )
1548
1542
1549
1543
// create invalid Client Encryption options with expired credentials
1550
1544
expiredClientEncryptionOptions := options .ClientEncryption ().
1551
1545
SetKmsProviders (expiredKmsProviders ).
1552
1546
SetKeyVaultNamespace (kvNamespace ).
1553
- SetTLSConfig (tlsConfig )
1547
+ SetTLSConfig (map [string ]* tls.Config {
1548
+ "aws" : caTLSConfig ,
1549
+ "azure" : caTLSConfig ,
1550
+ "gcp" : caTLSConfig ,
1551
+ "kmip" : caTLSConfig ,
1552
+ })
1554
1553
1555
1554
// create invalid Client Encryption options with invalid hostnames
1556
1555
invalidHostnameClientEncryptionOptions := options .ClientEncryption ().
1557
1556
SetKmsProviders (invalidKmsProviders ).
1558
1557
SetKeyVaultNamespace (kvNamespace ).
1559
- SetTLSConfig (tlsConfig )
1558
+ SetTLSConfig (map [string ]* tls.Config {
1559
+ "aws" : caTLSConfig ,
1560
+ "azure" : caTLSConfig ,
1561
+ "gcp" : caTLSConfig ,
1562
+ "kmip" : caTLSConfig ,
1563
+ })
1560
1564
1561
1565
awsMasterKeyNoClientCert := map [string ]interface {}{
1562
1566
"region" : "us-east-1" ,
@@ -1622,7 +1626,8 @@ func TestClientSideEncryptionProse(t *testing.T) {
1622
1626
1623
1627
possibleErrors := []string {
1624
1628
"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
1626
1631
"x509: certificate is not authorized to sign other certificates" , // All others
1627
1632
}
1628
1633
0 commit comments