Hi,
I’m testing MongoDB with TLS, and can connect from Mongo Compass, but cannot from code (golang). It shown an error as below:
uri mongodb://192.168.1.70,192.168.1.75,192.168.1.72:27017/?ssl=true&tlsCAFile=./mongoCA.crt&tlsCertificateKeyFile=./vps1.pem&tlsCertificateKeyFilePassword=12344321
Ping error server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: 192.168.1.70:27017, Type: Unknown, Last error: connection() error occured during connection handshake: x509: cannot validate certificate for 192.168.1.70 because it doesn't contain any IP SANs }, { Addr: 192.168.1.75:27017, Type: Unknown, Last error: connection() error occured during connection handshake: x509: cannot validate certificate for 192.168.1.75 because it doesn't contain any IP SANs }, { Addr: 192.168.1.72:27017, Type: Unknown, Last error: connection() error occured during connection handshake: x509: cannot validate certificate for 192.168.1.72 because it doesn't contain any IP SANs }, ] }
this is my mongod.conf
net:
port: 27017
bindIp: 0.0.0.0
tls:
mode: preferTLS
certificateKeyFile: /home/vps1/x509/vps1.pem
CAFile: /home/vps1/x509/mongoCA.crt
clusterFile: /home/vps1/x509/vps1.pem
certificateKeyFilePassword: 12344321
clusterPassword: 12344321
security:
authorization: enabled
clusterAuthMode: x509
I searched for answers but found no result about Mongo. Can anyone help me to solve this problem?