Skip to content

Instantly share code, notes, and snippets.

@tonybaines
Created October 22, 2019 13:58
Show Gist options
  • Save tonybaines/ba548f405eb340a4cf52d9b835790275 to your computer and use it in GitHub Desktop.
Save tonybaines/ba548f405eb340a4cf52d9b835790275 to your computer and use it in GitHub Desktop.
openssl commands for public key stuff without interaction
openssl req -newkey rsa:4096 -nodes -keyform PEM \
-subj "/C=GB/ST=Suffolk/L=Ipswich/O=foobar/CN=trust.foobar.com" \
-keyout etc/CA.key -x509 -days 9999 -outform PEM -out etc/CA.pem
openssl genrsa -out etc/client.key 4096 && \
openssl req -new -key etc/client.key -out etc/client.req \
-subj "/C=GB/ST=Suffolk/L=Ipswich/O=foobar/CN=client.foobar.com" && \
openssl x509 -req -in etc/client.req -CA etc/CA.pem -CAkey etc/CA.key -set_serial 101 \
-extensions client -days 9999 -outform PEM -out etc/client.pem && \
openssl x509 -in etc/client.pem -outform DER | openssl dgst -sha256 | \
cut -d" " -f2 | tr 'A-Z' 'a-z' > etc/client.sha256 && \
rm etc/client.req
openssl req -new -newkey rsa:4096 -days 9999 -nodes -x509 \
-subj "/C=GB/ST=Suffolk/L=Ipswich/O=foobar/CN=untrusted.foobar.com" \
-keyout etc/untrusted.key -out etc/untrusted.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment