简体   繁体   中英

Mongodb Java driver won't connect via TLS

Im trying to connect to my mongoDb over TLS. Therefore i started the daemon with following arguments:

mongod --sslMode requireSSL --sslPEMKeyFile <pem> --sslCAFile <ca>

I imported my rootCA into a Java keystore and set it via JVM Arguments in my Java Client Application (Springboot). I also set TLS to version 1.1 via a JVM Argument.

However im getting following error:

com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to 
connect. Client view of cluster state is {type=Unknown, servers= 
[{address=10.0.2.103:27017, type=Unknown, state=Connecting, exception= 
{com.mongodb.MongoException$Network: Exception opening the socket}, caused 
by {javax.net.ssl.SSLHandshakeException: Remote host closed connection 
during handshake}, caused by {java.io.EOFException: SSL peer shut down 
incorrectly}}]

My certificates are signed with my own CA.

I read online somethings about clientcertificates, but shouldnt be the CA enough to validate that the server has a valid Certificate?

EDIT: Solved the problem by installing a mongodb with SSL support. Now ive ran into another Problem. Ive imported my ca.pem into my truststore and imported my client.pem into my keystore (and also set them in my springboot properties). But the mongodb server always states: "no SSL certificate provided by peer". Why does this happen?

I solved my problem by installing another MongoDB version which included SSL support. The one i had didnt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM