title: How to use the Windows Keystore (MCS) with JDBC?
body: <p>I am trying to create a java application that uses <code>PKI</code> for authentication. I need to be able to retrieve a certificate from the Microsoft Certificate Store (MCS) and pass it along to an Oracle database (11.2). </p>
  
  <p>I am connecting using the <code>jdbc:oracle:thin</code> driver. After spending quite some time on google I have come up empty. 
  I've found different properties to change (depending on the article):</p>
  
  <ul>
  <li>set the property <code>javax.net.ssl.keyStoreType = "Windows-MY"</code> </li>
  <li>set the <code>javax.net.ssl.keyStore = "Windows-MY"</code> </li>
  <li><code>javax.net.ssl.keyStore should be set to "None"</code> (if using a custom KeyManager which I do not believe will work since by the time it gets into my custom KeyManager I will already be given the certs from a keystore specified in the connection properties). </li>
  </ul>
  
  <p>Of course all of these people are claiming success, but nothing has worked for me. I have tried every example I have been able to find all with no luck.  I was able to successfully authenticate when I was using Oracle wallets so I know my certificates are fine. If anyone has done this before and is willing to post some code that would be great. </p>
  
  <p>I know most people are using the Windows keystore with a website and therefore are creating their own SSLContext, but I cannot imagine I am the only one who has wanted to do this using JDBC (which as far as I know does not allow me to provide it an SSLContext).</p>
  
  <p>This is the code that I believe should work, but does not.</p>
  
  <pre><code>DriverManager.registerDriver)new OracleDriver());
  String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=host)(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=someName))(SECURITY= (SSL_SERVER_CERT_DN=\"CN=TESTSERVER\")))";
  
  java.util.Properties props = new java.util.Properties();
  props.setProperty("javax.net.ssl.keyStoreType", "Windows-MY");
  props.setProperty("javax.net.ssl.keyStore", "NONE");
  props.setProperty("javax.net.ssl.trustStoreType", "Windows-ROOT");
  props.setProperty("javax.net.ssl.trustStore", "NONE");
  
  props.setProperty("oracle.net.ssl_server_dn_match", "true");
  props.setProperty("oracle.net.authentication_services", "(TCPS)");
  Connection conn = DriverManager.getConnection(url, props);
  </code></pre>
  
  <p>This code fails with the exception:</p>
  
  <pre><code>java.sql.SQLRecoverableException: IOException: The Network Adapter could not establish the connection
  </code></pre>