3

I've configured a standard database connection, I connect to an Oracle database. The database will be configured to use SSL, this means that I'll need to specify the server certificate in order to connect.

The SSL itself is with SSL_CLIENT_AUTHENTICATION=FALSE and configured a Oracle Wallet.

Can it be done using JDBC?

This is my current code:

        Class.forName("oracle.jdbc.OracleDriver");

        connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.200.96:1521:NNVSDB", "VSU22","VSU22");
David Faizulaev
  • 4,651
  • 21
  • 74
  • 124
  • Might wanna take a look at [this](https://docs.oracle.com/cd/B19306_01/java.102/b14355/sslthin.htm#BABJIHFJ) – Gurwinder Singh Dec 18 '16 at 15:55
  • Possible duplicate of http://stackoverflow.com/questions/10415733/jdbc-connection-to-oracle-database-using-tls-certificate (not voting to close, as that question + my answer are 4 years old, and I'm not sure if things have changed/improved since then). – Mark Rotteveel Dec 18 '16 at 16:27
  • were you able to figure outthe configuration? – yolob 21 Apr 15 '20 at 12:30

1 Answers1

6

You can find a pdf with some documentation here : SSL With Oracle JDBC, you have some code example page 11 and 12:

String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=servername)(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=servicename)))"); 
Properties props = new Properties(); 
props.setProperty("user", "scott"); 
props.setProperty("password", "tiger"); 
props.setProperty("javax.net.ssl.trustStore", 
                  "/truststore/ewallet.p12"); 
props.setProperty("javax.net.ssl.trustStoreType","PKCS12"); 
props.setProperty("javax.net.ssl.trustStorePassword","welcome123"); 
Connection conn = DriverManager.getConnection(url, props); 
Xephi
  • 431
  • 2
  • 9
  • I saw this example, but I use a Wallet not a truststore. – David Faizulaev Dec 18 '16 at 16:07
  • 1
    Yeap, you have two type of Wallet : SSO and PKCS12, you can either set property for SSO, where you don't even need password `props.setProperty("javax.net.ssl.trustStore", "/truststore/cwallet.sso"); props.setProperty("javax.net.ssl.trustStoreType","SSO");` – Xephi Dec 18 '16 at 16:14
  • @DavidFaizulaev Could you please post the listener,sqlnet & tnsnames.ora, I am attempting to configure the jdbc with ssl using oracle wallets but failing to do so – yolob 21 Apr 15 '20 at 12:29