Tomcat JDBC certified MySQL SSL Encryption

Source: Internet
Author: User
Tags ssl certificate ssl connection

Recently, the company did three level certification, nor how to update the Java blog, the recent busy is updated. One of the three-level certifications has a very interesting feeling:

General company MYSQL/MARIADB Tomcat doing JDBC authentication is generally the case:

Db.default.driver=com.mysql.jdbc.driverdb.default.url= "Jdbc:mysql://url.to.database/database" db.default.user= " ... "//mysql user name db.default.password=" ... "//MySQL Password ...//other parameter optimization

In other words, in addition to the user name, password, IP, port, basic tuning, you can.

However, if the database uses an SSL encrypted connection, the connection must be a certificate. As a result of my interest, after the inquiry, the general process is this, share:

1. mysql Issue certificate configuration

[Mysqld]ssl #开启ssl功能ssl-ca=/etc/mysql/ssl/cacert.pem #指定CA文件位置ssl-cert=/etc/mysql/ssl/master.crt #指定证书文件位置ssl-key =/etc/mysql/ssl/master.key #指定密钥所在位置

2. Keytool Import Certificate

Keytool-import-alias mysqlservercacert-file Cacert.pem.pem-keystore Mysqlservercacertssl.jks

3. JDBC Related parameters:

eg

Db.default.url= "jdbc:mysql://url.to.database/test_db?verifyservercertificate=true&usessl=true& Requiressl=true "

Verifyservercertificate=true--Deny cannot confirm certificate if host is connected (using SSL certificate)

Usessl=true--Use SSL connection.

Requiressl=true--Deny if the MySQL server does not support SSL connections.


4. Specify your own Mysqlservercacertssl.jsk

Export java_opts= "-djavax.net.ssl.keystore=/usr/local/etc/tomcat/certs/mysqlservercacertssl.jsk- djavax.net.ssl.keystorepassword=password-djavax.net.ssl.truststore=/usr/local/etc/tomcat/certs/ Mysqlservercacertssl.jsk-djavax.net.ssl.truststorepassword=password "

The same:

-djavax.net.ssl.keystore=path_to_keystore_file-djavax.net.ssl.keystorepassword= Password-djavax.net.ssl.truststore=path_to_truststore_file-djavax.net.ssl.truststorepassword=password

5. Restart Tomcat

/etc/init.d/tomat restart

6. Precautions:

6.1) MySQL supports SSL and ensures login verification.

6.2) Account authorization.

6.3) Certificate Rights Management.

6.4) Consider the problem with SSL. (The actual situation to be specific analysis, otherwise will bring many problems)

This article is from "Never give up!" Ningzhiyuan "blog, declined reprint!

Tomcat JDBC certified MySQL SSL Encryption

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.