Skip to content

Instantly share code, notes, and snippets.

@chaitanyagupta
Last active November 5, 2024 10:38
Show Gist options
  • Save chaitanyagupta/8e983f5148675d06d329fc6f82b4356b to your computer and use it in GitHub Desktop.
Save chaitanyagupta/8e983f5148675d06d329fc6f82b4356b to your computer and use it in GitHub Desktop.
Using OpenSSL to generate a CSR and packaging the certs and private key in a .p12 file
  • generate an RSA key
    openssl genrsa -out domain_name.key 2048
    
  • generate a certificate signing request (CSR) using the private key
    openssl req -new -sha256 -key domain_name.key -out domain_name.csr
    
  • verify that public key in the certificate matches the private key
    openssl x509 -in domain_name.crt -noout -modulus | md5
    openssl rsa -in domain_name.key -noout -modulus | md5
    
  • create a .p12 file with cert chain and private key
    cat *.crt | openssl pkcs12 -export -inkey domain_name.key -out domain_name.p12
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment