title: Use two different custom KeyStore in Scala
body: <p>I'm developing an application in Scala language having 2 interfaces. For the first the app behavies as a server, for the second one behavies as a client. I want HTTPS secure connection (mutual authentication) in both sides. Now, I've tried to split the keystore such a way an instance contains the certificate for the first interface, and another instance contains the certificate for the second interface. So, I've instantiated 2 variables of KeyStore, passing different certificates and then initialized the 2 different KeyManagerFactory. Finally, I initialize 2 different SSLContext in order to use them in the HTTPS connection. Enabling ssl: handshake debug I can see this:</p>
  <pre><code> *** ServerHelloDone
  Warning: no suitable certificate found - continuing without client authentication
  *** Certificate chain
  &lt;Empty&gt;
  ***
  </code></pre>
  <p>It seems that my application isn't able to satisfy the CertificateRequest of the server (this debug is related to client side) while the connection in server side goes well.
  So, my question is: Can I use two different keystore (and KeyManagerFactory) or java doesn't support that? How can I do this operation?</p>
  <p>UPDATE</p>
  <p>I've just read that I can use only one KeyStore (my previous solution was one KeyStore with two certificates) with X509ExtendedKeyManager and use the method chooseClientAlias() to select what certificate use. Anyone knows how can I do this improvement?</p>