connect mysql server from spring boot application with SSL
Hello Techrunnr, this document deals which how to connect mysql server from spring boot application with SSL enabled.
All the applications interact with the database in order to get data for your web application. It’s always better and recommended to have encrypted communication between database and web application. Setting up of an encrypted connection between these two is very simple and easy.
Here are the steps connect MySQL server from spring boot application with SSL enabled.
* Java installed machine, if not installed follow this link
* Mysql Server installed and running, if not follow this link
Generate SSL certificate in Database server.
NOTE: Make sure Common name should be different
1. Generate CA Certificate
2. Create Server Certifcate and Sign with CA
3. Create Client certificate, Sign with CA
4. Verify the Certificate
After generating the certificates, verify certificates are correct
You should get output like this.
Enter the following statements in my.cnf
Restart the MySQL service to take effect new configuration.
5. Verify the SSL configuration.
Login to mysql server
6. Generate trustore certificate.
Trust this certificate? [no]: yes
7. Generate Keystore Certificate for client certificate
openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem -passout pass:mypass -out client-keystore.p12
8. Change the JDBC connection to use SSL in application properties.
© 2018, Techrunnr. All rights reserved.