1
votes

I am trying to connect to Oracle using PKI. I follow this link

http://www.oracle.com/technetwork/topics/wp-oracle-jdbc-thin-ssl-130128.pdf

public static void main(String[] args) throws Exception {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    String addr = "DESKTOP-BH1RKUF";
    String service = "orcl";
    String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=" + addr + ")(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=" + service + ")))";
    Properties props = new Properties();
    // props.setProperty("user", "sys as sysdba");
    // props.setProperty("password", "password");
    props.setProperty("javax.net.ssl.keyStore", "/Users/user/Downloads/client/keystore.jks");
    props.setProperty("javax.net.ssl.keyStoreType", "JKS");

    props.setProperty("javax.net.ssl.trustStore", "/Users/user/Downloads/client/truststore.jks");
    props.setProperty("javax.net.ssl.trustStoreType", "JKS");
    props.setProperty("oracle.net.authentication_services", "(TCPS)");
    props.setProperty("oracle.net.ssl_version", "1.0");
    props.setProperty("javax.net.ssl.keyStorePassword", "Passw0rd");
    props.setProperty("javax.net.ssl.trustStorePassword", "Passw0rd");


    try (Connection conn = DriverManager.getConnection(url, props)) {
       System.out.println(conn.getClass());
    }
}

I am getting this error: ORA-01017: invalid username/password; logon denied

Exception in thread "main" java.sql.SQLException: ORA-01017: invalid 
username/password; logon denied
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:461)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:394)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:386)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:1121)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:502)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:541)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:264)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:435)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:1020)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:707)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:755)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:599)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at com.xyz.oracle.jdbc.pool.Test.main(Test.java:29)

Please refer to the full log: https://uploadfiles.io/qv4zg

If I set user and password, it works fine.

1

1 Answers

0
votes

If you're trying to follow case #4 of the whitepaper that you have mentioned, e.g. "USE SSL AS AN AUTHENTICATION SERVICE IN THE DATABASE" then you must follow all the steps including "create user sslclient identified externally as 'CN=client_test,C=US';". This specific database user doesn't have any password. The only way to connect using this user is to provide a valid certificate that has the right distinguished name on the client. I'm guessing that you haven't done that because you mention that it works if you provide a user and password.