title: MongoDB ssl in java works only with intermediate certificate
body: <p>I'm using MongoDB 2.6.3 with SSL connection.<br>
  I am not using client validation, and the SSL configuration is only:</p>
  
  <blockquote>
    <p>sslMode = requireSSL<br>
      sslPEMKeyFile = /path/to/MyServerCertificate.pem</p>
  </blockquote>
  
  <p>The certificate I'm using is signed, and issued to my server by CA which have root CA like so:<br>
  RootCA ---> SignerCA ---> MyServerCertificate  </p>
  
  <p><strong>The problem is:</strong>  I'm trying to connect via java by specifying trust store with <strong>only the SignerCA</strong>, and everything works fine. But when I'm specifying trust store with <strong>only the RootCA</strong>, I get:  </p>
  
  <blockquote>
    <p>com.mongodb.MongoServerSelectionException: Unabe to connect to any server </p>
  </blockquote>
  
  <p>In the mongo log I can see:  </p>
  
  <blockquote>
    <p>ERROR: SSL: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown</p>
  </blockquote>
  
  <hr>
  
  <p>My java code:</p>
  
  <pre><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());
  </code></pre>
  
  <p>When the keystore I'm using contain only RootCA I'm unable to connect for some reason...<br>
  I will be happy for suggestions. Thanks.</p>