I'm using MongoDB 2.6.3 with SSL connection.
I am not using client validation, and the SSL configuration is only:
sslMode = requireSSL
sslPEMKeyFile = /path/to/MyServerCertificate.pem
The certificate I'm using is signed, and issued to my server by CA which have root CA like so:
RootCA ---> SignerCA ---> MyServerCertificate
The problem is: I'm trying to connect via java by specifying trust store with only the SignerCA, and everything works fine. But when I'm specifying trust store with only the RootCA, I get:
com.mongodb.MongoServerSelectionException: Unabe to connect to any server
In the mongo log I can see:
ERROR: SSL: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown
My java code:
Builder options = MongoClientOptions.builder();
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream("path/to/keystore"), "pass".toCharArray());
TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustFactory.init(ks);
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustFactory.getTrustManagers(), null);
options.socketFactory(sc.getSocketFactory());
new MongoClient("loclahost", options.build());
When the keystore I'm using contain only RootCA I'm unable to connect for some reason...
I will be happy for suggestions. Thanks.