I am trying to create a Java application that uses PKI for authentication. I need to get the certificate from the Microsoft Certificate Store (MCS) and transfer it to the Oracle database (11.2).
I connect using the jdbc:oracle:thin driver. After spending quite a lot of time on google, I went up empty. I found different properties to change (depending on the article):
- set property
javax.net.ssl.keyStoreType = "Windows-MY" - set
javax.net.ssl.keyStore = "Windows-MY" javax.net.ssl.keyStore should be set to "None" (if you use a custom KeyManager, which, I believe, will not work, since from the moment it is entered into my custom KeyManager, certificates from the key store specified in connection properties).
Of course, all these people claim to be successful, but nothing worked for me. I tried every example, I could find everything without luck. I was able to successfully authenticate when I used Oracle wallets, so I know that my certificates are fine. If someone has done this before and is ready to post some code that would be great.
I know that most people use the Windows keystore with a website and therefore create their own SSLContext, but I cannot imagine that I am the only one who wanted to do this using JDBC (which, as far as I know, does not allow me to provide him with SSLContext).
This is code that I think should work, but does not.
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);
This code fails with the exception:
java.sql.SQLRecoverableException: IOException: The Network Adapter could not establish the connection
java ssl oracle11g jdbc jsse
Ben
source share