Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3924

Read certificate files async

    • 2
    • 2
    • Not Needed
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?

      The reading of the files provided to the tlsCAFile and tlsCertificateKeyFile connection options will now be done on the first call to MongoClient.connect.

      Relevant documentation pages:

      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      N/A

      3. Which versions of the driver/connector does this apply to?

      driver >= v6

      Show
      1. What would you like to communicate to the user about this feature? The reading of the files provided to the tlsCAFile and tlsCertificateKeyFile connection options will now be done on the first call to MongoClient.connect . Relevant documentation pages: https://www.mongodb.com/docs/drivers/node/current/fundamentals/connection/tls/ https://www.mongodb.com/docs/drivers/node/current/fundamentals/connection/connection-options/ 2. Would you like the user to see examples of the syntax and/or executable code and its output? N/A 3. Which versions of the driver/connector does this apply to? driver >= v6

      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

            Assignee:
            warren.james@mongodb.com Warren James
            Reporter:
            daria.pardue@mongodb.com Daria Pardue
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: