Skip to content

Instantly share code, notes, and snippets.

@jarrod180
Last active December 18, 2024 10:21
Show Gist options
  • Select an option

  • Save jarrod180/82b94a132584362e4d351e224fec9516 to your computer and use it in GitHub Desktop.

Select an option

Save jarrod180/82b94a132584362e4d351e224fec9516 to your computer and use it in GitHub Desktop.
Create a CA and self signed certificates for testing locally using openssl
# Create a CA key
openssl genrsa 2048 > ca-key.pem
# Create a CA cert
openssl req -new -x509 -nodes -days 365000 -key ca-key.pem -out ca-cert.pem
# Create a server key
openssl req -newkey rsa:2048 -nodes -days 365000 -keyout server-key.pem -out server-req.pem
# Create a client key
openssl req -newkey rsa:2048 -nodes -days 365000 -keyout client-key.pem -out client-req.pem
# Create a server cert
openssl x509 -req -days 365000 -set_serial 01 -in server-req.pem -out server-cert.pem -CA ca-cert.pem -CAkey ca-key.pem
# Create a client cert
openssl x509 -req -days 365000 -set_serial 02 -in client-req.pem -out client-cert.pem -CA ca-cert.pem -CAkey ca-key.pem
# Create a client p12
openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem -out client.p12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment