[GODRIVER-706] SetSSL marks value as set when they are empty/nil Created: 14/Dec/18  Updated: 14/Dec/18  Resolved: 14/Dec/18

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 0.1.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: David Golden Assignee: David Golden
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates GODRIVER-688 ClientOptions.SetSSL() records some s... Closed

 Description   

SetSSL unconditionally sets connection string "*Set" variables to true, even if their corresponding inputs are empty/nil.  E.g. c.ConnString.SSLClientCertificateKeyFileSet = true. This is a regression of

A patch like the following should fix the problem:

-   c.ConnString.SSLClientCertificateKeyFile = ssl.ClientCertificateKeyFile
-   c.ConnString.SSLClientCertificateKeyFileSet = true
+   if ssl.ClientCertificateKeyFile != "" {
+       c.ConnString.SSLClientCertificateKeyFile = ssl.ClientCertificateKeyFile
+       c.ConnString.SSLClientCertificateKeyFileSet = true
+   }
 
-   c.ConnString.SSLClientCertificateKeyPassword = ssl.ClientCertificateKeyPassword
-   c.ConnString.SSLClientCertificateKeyPasswordSet = true
+   if ssl.ClientCertificateKeyPassword != nil {
+       c.ConnString.SSLClientCertificateKeyPassword = ssl.ClientCertificateKeyPassword
+       c.ConnString.SSLClientCertificateKeyPasswordSet = true
+   }
 
    c.ConnString.SSLInsecure = ssl.Insecure
    c.ConnString.SSLInsecureSet = true
 
-   c.ConnString.SSLCaFile = ssl.CaFile
-   c.ConnString.SSLCaFileSet = true
+   if ssl.CaFile != "" {
+       c.ConnString.SSLCaFile = ssl.CaFile
+       c.ConnString.SSLCaFileSet = true
+   }

Alternatively, the SSLOpt type should gain *Set booleans, a constructor and mutators and SetSSL should check those booleans.



 Comments   
Comment by David Golden [ 14/Dec/18 ]

Dup of GODRIVER-688

Generated at Thu Feb 08 08:34:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.