Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-3435

Localhost connection fails when `InsecureSkipVerify=true` is set

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Go Drivers
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      I'm running a local server for local development and an Atlas serverless instance for testing in the cloud (GCP Cloud Run container instance). In the cloud instance the connection certificate is not accepted by my container, probably because the container lacks root CA certs, but I've not investigated, that's not the issue.

      To make Cloud Run container work I've added
      SetTLSConfig(&tls.Config{InsecureSkipVerify: true{color}})
      option for the client initiation, to ignore certificate issues. In early development this is acceptable.

      However, when I then tried to connect to my local instance - I encountered an odd failure.

      My local instance is a replica set, and my connection string is:
      mongodb://localhost:54512/?directConnection=true&serverSelectionTimeoutMS=2000
      Using Compass I can connect no problem, but my system bootstrap fails with the following error:
      ```
      failed to create executor: failed to bootstrap system dependencies: failed to bootstrap system dependencies: failed to create MongoDB client: failed to connect to MongoDB: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: localhost:54512, Type: Unknown, Last error: EOF }, ] }
      ```
      If I remove the `SetTLSConfig` option, all other things being equal - everything works just fine. Putting it back in - fails my connection again.

      It seems that calling `SetTLSConfig()` affects some other options, however, it shouldn't since I've not set any other values in the config apart from the `InsecureSkipVerify` flag.

      Definition of done

      `InsecureSkipVerify` should not affect other parameters of the connection.

      Environment

      • go.mongodb.org/mongo-driver v1.17.1
      • MongoDB Compass: Version 1.44.6
      • Local DB: MongoDB 8.0.3 AtlasLocalDev
      • MacOS Sonoma 14.6.1 (23G93) MBP M1

            Assignee:
            matt.dale@mongodb.com Matt Dale
            Reporter:
            alex@bricktech.xyz Alex Kotenko
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: