我們配置了我們的Oracle 11g(v11.2.0)數據庫以使用SSL加密(Oracle Advanced Security)。 我們是按照SSL中的說明Oracle JDBC Thin Driver。只有加密,沒有認證,這是白皮書中的「案例1」。Tomcat webcontainer - 如何訪問ssl加密oracle數據庫
接下來,我們開發了一個小型測試客戶端來檢查我們是否可以訪問現在加密的數據庫。 這裏有點代碼:
String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=our_host)"
+ "(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=our_service_name)))";
System.out.println("set properties");
Properties props = new Properties();
props.setProperty("user", "system");
props.setProperty("password", "our_password");
props.setProperty("oracle.net.ssl_cipher_suites",
"(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, "
+ "SSL_DH_anon_WITH_RC4_128_MD5,"
+ "SSL_DH_anon_WITH_DES_CBC_SHA)");
System.out.println("get connection");
Connection con = DriverManager.getConnection(url, props);
System.out.println("got a connection");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select sysdate from dual");
while (rs.next()) {
System.out.println("result = "+rs.getString(1));
}
rs.close();
stmt.close();
con.close();
這工作得很好,吐出來的是正確的值。但唉,只是一個測試客戶端。現在我們必須配置我們的Tomcat(v7.0.21)webcontainer,以便我們的Web應用程序可以訪問現在加密的數據庫。 加密之前,我們使用了{tomcat.home}/conf/context.xml
一個dataSource
它是這樣的:
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="our_name" auth="Container"
driverClassName="oracle.jdbc.driver.OracleDriver" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
type="javax.sql.DataSource" logAbandoned="true" maxActive="30"
maxIdle="5" maxWait="1000" removeAbandoned="true"
removeAbandonedTimeout="60" url="jdbc:oracle:thin:@our_host:1521:our_sid"
username="admin_user" password="admin_user" validationQuery="select sysdate from dual"
testOnReturn="true" />
<!-- more Resources ... -->
</Context>
我有一對夫婦的設置的我在一些帖子在互聯網上找到(<Connector>
例如,在server.xml
擺弄周圍 - 見下文 - ,改jdbc瘦驅動器url等),但什麼都沒有實現。我不知道如何繼續,甚至如何調試。
我的註釋去掉,並測試(失敗)的連接器{tomcat.home}/conf/server.xml
:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="200" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
ciphers="SSL_DH_anon_WITH_DES_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5, SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" />
我們希望通過.xml文件來做到這一點,因爲我們以前一樣,所以我們並不需要推出一款新版本給我們的客戶。
如果您需要更多信息,如果您告訴我如何以及在何處找到它,我很樂意爲您提供一切。
謝謝您的時間,
問候
勒