How to configure spring boot application to use SSL/TLS over MySQL?

后端 未结 2 1413
野性不改
野性不改 2021-02-02 04:30

I set up SSL on my MySQL server.

I generated few certicates for CA (ca.pem, ca-key.pem), for client (client-cert.pem, client-key.pem) and server (server-cert.pem and se

2条回答
  •  时光取名叫无心
    2021-02-02 04:54

    Check my answer: https://stackoverflow.com/a/51879119/173149

    I don't like to pollute java options or system properties, which are useless in application containers in any case...

    You can set SSL certificate for MySQL connection programmically with:

    jdbc:mysql://example.com:3306/MYDB?verifyServerCertificate=true&useSSL=true&requireSSL=true&clientCertificateKeyStoreUrl=file:cert/keystore.jks&clientCertificateKeyStorePassword=123456&trustCertificateKeyStoreUrl=file:cert/truststore.jks&trustCertificateKeyStorePassword=123456

    It is documented:

    • https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
    • https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-using-ssl.html

提交回复
热议问题