Last active
December 12, 2019 08:11
-
-
Save andybeak/201a30d640a96ed9fe0963541093e0d5 to your computer and use it in GitHub Desktop.
Create MySQL certificates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://dev.mysql.com/doc/refman/5.7/en/creating-ssl-files-using-openssl.html | |
# Create clean environment | |
rm -rf newcerts | |
mkdir newcerts && cd newcerts | |
# Create CA certificate | |
# Use default values for everything except common name | |
openssl genrsa 2048 > ca-key.pem | |
openssl req -new -x509 -nodes -days 3600 -key ca-key.pem -out ca.pem | |
# Create server certificate, remove passphrase, and sign it | |
# server-cert.pem = public key, server-key.pem = private key | |
# Use default values for everything except common name and use a different CN from CA | |
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout server-key.pem -out server-req.pem | |
openssl rsa -in server-key.pem -out server-key.pem | |
openssl x509 -req -in server-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem | |
# Create client certificate, remove passphrase, and sign it | |
# client-cert.pem = public key, client-key.pem = private key | |
# Use default values for everything except common name and use a different CN from CA and server | |
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout client-key.pem -out client-req.pem | |
openssl rsa -in client-key.pem -out client-key.pem | |
openssl x509 -req -in client-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment