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

Expired TLS certificate error reports code as error message

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.5.0
    • Affects Version/s: None
    • Component/s: None
    • 2
    • Not Needed
    • Hide

      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.

      Show
      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      "CERT_HAS_EXPIRED" has become the error message instead of "certificate has expired"

      // 6.3.0
      MongoServerSelectionError: certificate has expired
          at EventTarget.<anonymous> (./node_modules/mongodb-6.3.0/lib/sdam/topology.js:276:34)
          at [nodejs.internal.kHybridDispatch] (node:internal/event_target:826:20)
          at EventTarget.dispatchEvent (node:internal/event_target:761:26)
          at abortSignal (node:internal/abort_controller:371:10)
          at TimeoutController.abort (node:internal/abort_controller:393:5)
          at Timeout.<anonymous> (./node_modules/mongodb-6.3.0/lib/utils.js:1011:92)
          at listOnTimeout (node:internal/timers:573:17)
          at process.processTimers (node:internal/timers:514:7) {
        reason: TopologyDescription {
          type: 'Unknown',
          servers: Map(1) { 'expired.badssl.com:443' => [ServerDescription] },
          stale: false,
          compatible: true,
          heartbeatFrequencyMS: 10000,
          localThresholdMS: 15,
          setName: null,
          maxElectionId: null,
          maxSetVersion: null,
          commonWireVersion: 0,
          logicalSessionTimeoutMinutes: null
        },
        code: undefined,
        [Symbol(errorLabels)]: Set(0) {},
        [cause]: MongoNetworkError: certificate has expired
            at connectionFailureError (./node_modules/mongodb-6.3.0/lib/cmap/connect.js:379:20)
            at TLSSocket.<anonymous> (./node_modules/mongodb-6.3.0/lib/cmap/connect.js:285:22)
            at Object.onceWrapper (node:events:633:26)
            at TLSSocket.emit (node:events:518:28)
            at emitErrorNT (node:internal/streams/destroy:169:8)
            at emitErrorCloseNT (node:internal/streams/destroy:128:3)
            at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
          [Symbol(errorLabels)]: Set(1) { 'ResetPool' },
          [cause]: Error: certificate has expired
              at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
              at TLSSocket.emit (node:events:518:28)
              at TLSSocket._finishInit (node:_tls_wrap:1085:8)
              at ssl.onhandshakedone (node:_tls_wrap:871:12) {
            code: 'CERT_HAS_EXPIRED'
          }
        }
      }
      // 6.4.0
      MongoServerSelectionError: CERT_HAS_EXPIRED
          at EventTarget.<anonymous> (./node_modules/mongodb-6.4.0/lib/sdam/topology.js:292:34)
          at [nodejs.internal.kHybridDispatch] (node:internal/event_target:826:20)
          at EventTarget.dispatchEvent (node:internal/event_target:761:26)
          at abortSignal (node:internal/abort_controller:371:10)
          at TimeoutController.abort (node:internal/abort_controller:393:5)
          at Timeout.<anonymous> (./node_modules/mongodb-6.4.0/lib/utils.js:1008:92)
          at listOnTimeout (node:internal/timers:573:17)
          at process.processTimers (node:internal/timers:514:7) {
        reason: TopologyDescription {
          type: 'Unknown',
          servers: Map(1) { 'expired.badssl.com:443' => [ServerDescription] },
          stale: false,
          compatible: true,
          heartbeatFrequencyMS: 10000,
          localThresholdMS: 15,
          setName: null,
          maxElectionId: null,
          maxSetVersion: null,
          commonWireVersion: 0,
          logicalSessionTimeoutMinutes: null
        },
        code: undefined,
        [Symbol(errorLabels)]: Set(0) {},
        [cause]: MongoError: CERT_HAS_EXPIRED
            at onHeartbeatFailed (./node_modules/mongodb-6.4.0/lib/sdam/monitor.js:172:15)
            at ./node_modules/mongodb-6.4.0/lib/sdam/monitor.js:265:9
            at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
          [Symbol(errorLabels)]: Set(1) { 'ResetPool' },
          [cause]: 'CERT_HAS_EXPIRED'
        }
      }
      

      User Impact

      • Devtools, potentially external users

      Dependencies

      • connect(), socket creation error handling

      Unknowns

      • How is a string being treated as a cause?

      Acceptance Criteria

      Implementation Requirements

      • Ensure the message is in a helpful readable format

      Testing Requirements

      • Use the host below to check the message
      require("mongodb-6.4.0").MongoClient.connect("mongodb://expired.badssl.com:443/?tls=true&serverSelectionTimeoutMS=1000").catch(err => console.log(err))
      

      Documentation Requirements

      • None

      Follow Up Requirements

      • None

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: