我正在通过我的Java代码连接到oracle ssl侦听器。 Java代码在AWS Lambda中运行。为了通过SSL端口连接到oracle,我需要通过cwallet.sso证书。该证书采用base64编码,并存储在Vault中。我可以从Vault中以String形式获取证书的内容。我需要对base64进行解码并使用其内容来连接到oracle。在我在本地计算机中用于连接到oracle ssl端口的代码下面。由于我是从Vault中获取数据流的,因此有没有一种方法可以提供证书(cwallet.sso)而无需创建文件?
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Security.addProvider(new oracle.security.pki.OraclePKIProvider());
String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=<hostname>)(PORT=1522))(CONNECT_DATA=(SID=<SID>)))";
java.util.Properties info = new java.util.Properties();
ClassLoader classLoader = getClass().getClassLoader();
info.setProperty("javax.net.ssl.trustStore", Paths.get(classLoader.getResource("certs/cwallet.sso").toURI()).toString());
info.setProperty("javax.net.ssl.trustStoreType", "SSO");
info.setProperty("user", "username");
info.setProperty("password", "password");
Connection conn = DriverManager.getConnection(url, info);
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from table where rownum < 10");