Created
May 12, 2021 13:28
-
-
Save ryancheung/59bbd08e1e49016e4c396dfac43168ce to your computer and use it in GitHub Desktop.
Generate self signed CA, Server and Client certs for gRPC SSL Credentials
This file contains 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 | |
PASS=jing0518 | |
SERVER_HOST=localhost | |
CLIENT_HOST=localhost | |
#################################### | |
echo Generate CA key: | |
openssl genrsa -passout pass:$PASS -des3 -out Endless_ca.key 4096 | |
echo Generate CA certificate: | |
openssl req -passin pass:$PASS -new -x509 -days 3650 -key Endless_ca.key -out Endless_ca.crt -subj "/C=US/ST=CA/L=Cupertino/O=Endless/OU=Mir3/CN=Endless_RootCA" | |
#################################### | |
echo Generate server key: | |
openssl genrsa -passout pass:$PASS -des3 -out Endless_server.key 4096 | |
echo Generate server signing request: | |
openssl req -passin pass:$PASS -new -key Endless_server.key -out Endless_server.csr -subj "/C=US/ST=CA/L=Cupertino/O=Endless/OU=Mir3/CN=$SERVER_HOST" | |
echo Self-sign server certificate: | |
openssl x509 -req -passin pass:$PASS -days 3650 -in Endless_server.csr -CA Endless_ca.crt -CAkey Endless_ca.key -set_serial 01 -out Endless_server.crt | |
echo Remove passphrase from server key: | |
openssl rsa -passin pass:$PASS -in Endless_server.key -out Endless_server.key | |
#################################### | |
echo Generate client key | |
openssl genrsa -passout pass:$PASS -des3 -out Endless_client.key 4096 | |
echo Generate client signing request: | |
openssl req -passin pass:$PASS -new -key Endless_client.key -out Endless_client.csr -subj "/C=US/ST=CA/L=Cupertino/O=Endless/OU=Mir3/CN=$CLIENT_HOST" | |
echo Self-sign client certificate: | |
openssl x509 -passin pass:$PASS -req -days 3650 -in Endless_client.csr -CA Endless_ca.crt -CAkey Endless_ca.key -set_serial 01 -out Endless_client.crt | |
echo Remove passphrase from client key: | |
openssl rsa -passin pass:$PASS -in Endless_client.key -out Endless_client.key | |
#################################### | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment