-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
Currently, we read the certificate files synchronously when we parse them (tlsCAFile, tlsCertificateKeyFile). This is not good practice in Node, so we should fix it. However, since these values are then stored in ca, cert, and key properties respectively, we'd need a behavioral change where those properties just store the path and we cache the value elsewhere.
User Impact
- File reading errors will occur at connect time rather than client construction
Acceptance Criteria
Implementation Requirements
- Change the OPTIONS registry in connection_string.ts to capture the filenames instead of reading the files for all the tls/ssl options.
- Add logic to use the file names in MongoClient.connect to read the files using async readFile, use utf8 as the encoding
- Assign the contents of the file to the corresponding option (ex. caFileName -> ca), stored on the client options object
Testing Requirements
- Test that files are read at connection time
- Test that files are read only once even if connect is invoked again after closing the client
- Test that file names with zero length are ignored
Documentation Requirements
- Clarify in API docs on the MongoOptions type how the TLS files are read / at what time
- Document breaking change in the migration guide