我已经配置了在Oracle 11g数据库服务器使用一个钱包和自签名证书的SSL工作。 与本地客户端(SQLPLUS)测试它和它的作品没有任何问题。 现在,我尝试连接使用Java JDBC数据库。 目前,我得到一个错误:
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
这里是我的代码:
public static void main(String[] args)
{
Connection connection = null;
String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=192.168.200.191)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=VDB)))";
Properties props = new Properties();
props.setProperty("user", "dbuser");
props.setProperty("password", "dbpass");
props.setProperty("oracle.net.ssl_cipher_suites","(SSL_RSA_WITH_3DES_EDE_CBC_SHA)");
/* Load the database driver */
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
connection = DriverManager.getConnection(url,props);
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
catch (SQLException ex) {
ex.printStackTrace();
}
}
我做了一些调查研究,结果发现,如果钱包被配置为“AUTO_LOGIN”,我可以尝试以下方法:
Connection connection = null;
String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=192.168.200.191)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=VDB)))";
Properties props = new Properties();
props.setProperty("user", "dbuser");
props.setProperty("password", "dbpass");
props.setProperty("javax.net.ssl.trustStore", "C:\\oracle\\wallet\\cwallet.sso");
props.setProperty("javax.net.ssl.trustStoreType","SSO");
/* Load the database driver */
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
connection = DriverManager.getConnection(url,props);
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
catch (SQLException ex) {
ex.printStackTrace();
}
在这种情况下,我得到:
java.security.NoSuchAlgorithmException: SSO KeyStore not available
我已经添加了3罐:oraclepki.jar,osdt_cert.jar,osdt_core.jar试图运行代码的最后一个版本,让例外:
java.lang.ClassNotFoundException: com.phaos.crypto.AuthenticationException
也许我应该指定钱夹位置? 正如我在tnsnames.ora文件做了? 或者指定证书CN?
请指教,谢谢。