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

Mongo go driver - giving key mismatch error while connecting with ssl enabled and encrypted key

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      I'm getting following error while trying to connect to mongodb server from golang application kubernetes pod.
      tls: private key does not match public key

      I'm using mongo-go-driver version 1.4.1

      Key is RSA encrypted. ----BEGIN RSA PRIVATE KEY---- Proc-Type: 4,ENCRYPTED DEK-Info: ..

      PFB application code to connect
       {{ m.context, _ = context.WithTimeout(context.Background(), 30*time.Second)}}
      {{}}
      {{ certFilePath := <path>}}
      {{ keyPassword := <password>}}
      {{}}
      {{ uri := "mongodb://user:password@<mongoserver>:27017/?authSource=<dbname>&authMechanism=scram-sha-1&connect=direct&ssl=true&sslClientCertificateKeyFile=%s&sslClientCertificateKeyPassword=%s&sslInsecure=true&sslAllowInvalidCertificates=true" uri = fmt.Sprintf(uri, certFilePath, keyPassword)}}
      {{}}
      {{ log.Println("ConnectDB: creating mongo client new")}}
      {{ clientOptions := []*options.ClientOptions

      { options.Client().ApplyURI(uri),//.SetAuth(credential),}

      }}
      {{}}
      {{ log.Println("ConnectDB: connecting client") m.client, err = mongo.Connect(m.context, clientOptions...)if nil != err

      { panic(err)}

      }}
      Same key and certs are working fine when connecting using Robo 3T or Studio 3T

      Please help me in resolving key mismatch error. 

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            prakhar.deep12@gmail.com prakhar deep
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: