在context.xml中指定要用于jdbc的SSL [英] Specify SSL to be used for jdbc in context.xml
问题描述
我希望在使用Jersey和Tomcat的应用程序中使用我的jdbc连接,以使用SSL对其进行保护. mySQL服务器已经支持SSL,运行NetBeans的计算机上存在必需的SSL证书文件,并且可以使用来自MySQL Workbench的SSL连接到mySQL服务器.
I would like to have my jdbc connection used in the application using Jersey and Tomcat to be secured using SSL. The mySQL server already supports SSL, I have the necessary SSL certificate file present on the computer running NetBeans and I can connect to the mySQL server using SSL from MySQL Workbench.
当前不安全连接的定义如下:
The definition for an unsecured connection currently looks like:
<Resource name="jdbc/Colabo" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="xxxx" password="yyyyy" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://ip.address:3306/db?autoReconnect=true"/>
如何在context.cml文件的部分中指定应该使用SSL进行连接?
How can I specify in the section of the context.cml file the connection should be done using SSL?
推荐答案
受类似问题答案的启发-配置spring以进行连接到通过ssl的mysql .
Inspired by an answer to a similar question - Configure spring to connect to mysql over ssl.
可以在URL中传递SSL设置:
The SSL settings can be passed in the URL:
url="jdbc:mysql://ip.address:3306/db?autoReconnect=true&verifyServerCertificate=false&useSSL=true&requireSSL=true"/
我没有找到一种方法来使verifyServerCertificate=true
选项正常工作-可能需要指定CA证书的位置是该设置的一部分.
I did not find a way how to make the verifyServerCertificate=true
option working - one would probably need to specify a location of the CA certificate is some settings for that .
这篇关于在context.xml中指定要用于jdbc的SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!