Java Client Certificate Conflict
<p>I have a working app that connects to a lot of external services.  I'm adding a new SOAP client that requires client authentication.  I'm able to get it working, but not without breaking other things in the app, so I'm really confused as to what's going on.  Some quick background:</p>

<ol>
<li>We're using the default cacerts file and have imported a lot of trusted certs there.</li>
<li>We created a private key, generated a cert req from it, got a cert back, and created a p12 file containing the cert and private key that is used for client auth.</li>
<li>If we specify that p12 file as the keystore for the app the SOAP client works:</li>
</ol>

<p>-Djavax.net.ssl.keyStore="keystore.p12" -Djavax.net.ssl.keyStorePassword="password" -Djavax.net.ssl.keyStoreType="pkcs12"</p>

<ol start="4">
<li>If we do not do the above, but instead import this into the cacerts file doing:</li>
</ol>

<p>keytool -importkeystore -srckeystore keystore.p12 -destkeystore cacerts -srcstoretype pkcs12</p>

<p>it does NOT work!  Nor does it work if we do this and specify cacerts as the keystore per step 3 (excluding the last arg, as it's a different store type, right?)</p>

<p>So, with steps 1-3 we have our new integration working, but the problem is that other stuff in the app now breaks!  No other keystore was being specified before (my understanding is that it defaults to cacerts anyway).  We now have errors such as with AWS's SES (email) service throwing exceptions such as:</p>

<ul>
<li>java.lang.RuntimeException: Couldn't instantiate instance of class com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient</li>
<li>com.amazonaws.AmazonClientException: Unable to access default SSL context</li>
<li>java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)</li>
<li>java.security.UnrecoverableKeyException: Cannot recover key</li>
</ul>

<p>Can someone explain to me what's causing this conflict and how to resolve it?  Thanks much for your help!</p>

<p>Jeff</p>