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.