Skip to content

Instantly share code, notes, and snippets.

@yalattas
Last active September 23, 2024 01:28
Show Gist options
  • Save yalattas/34ccca8beeca95db76bcf37d99f25f27 to your computer and use it in GitHub Desktop.
Save yalattas/34ccca8beeca95db76bcf37d99f25f27 to your computer and use it in GitHub Desktop.
SSH-PEM-to-PFX

root

openssl pkcs12 -export -out rootca.pfx -in <FILE_NAME>.pem -nokeys

certificate

openssl pkcs12 -export -out mycert.pfx -inkey private.pem -in public.crt

root CA

root

  1. Generate Root key for root CA
openssl genrsa -out rootCA.key 4096
  1. Generate root certificate
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 3650 -out rootCA.crt

OR

openssl req -x509  -new -nodes -key rootCA.key \
  -days 3650 \
  -out rootCA.crt \
  -subj "/C=SA/ST=MK/L=MVT/O=<ORG>/OU=Cloud/CN=<COMMON_NAME>"

SSL using custom CA

  1. Generate Server key (private) for certificate
openssl genrsa -out server.key 2048
  1. Create a Certificate Signing Request (CSR) for the Client/Server
openssl req -new -key server.key -out server.csr
  1. Sign CSR with custom root CA
openssl x509 -req -in server.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out server.crt -days 365 -sha256

verify

openssl verify -CAfile rootCA.crt server.crt

server.crt: OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment