Skip to content

Instantly share code, notes, and snippets.

@nipunthathsara
Created September 19, 2022 19:35
Show Gist options
  • Save nipunthathsara/aa10dd2d3e7b9b5a2011150d96bd2c24 to your computer and use it in GitHub Desktop.
Save nipunthathsara/aa10dd2d3e7b9b5a2011150d96bd2c24 to your computer and use it in GitHub Desktop.
OpenSSL commands
# Generate new RSA private key with genpkey.
genpkey -algorithm RSA -out private.key -pass pass:ggg -pkeyopt rsa_keygen_bits:4096 -outform PEM
# Generate new RSA private key with genrsa.
genrsa -out private.key -passout pass:gg 4096
# Read private key details
# '-noout' omits the ENCODED output getting printed in the result.
rsa -text -in private.key -noout
# Or
openssl rsa -in privateKey.key -check
# Read public key details
rsa -pubin -text -in public.key -noout
# Determine if any key file is on DER or PEM format.
# Open the file in a text editor. If it has BEGIN CERTIFICATE and END CERTIFICATE sections, it's PEM.
# Create interactive CSR from private key. (PEM format)
req -new -key private.key -out abc.com.csr
# Or
req -out abc.com.csr -key private.key -new
# Create non-interactive CSR from private key
req -new -key private.key -out abc.com.csr -subj "/C=US/ST=Utah/L=Lehi/O=Your Company, Inc./OU=IT/CN=yourdomain.com"
# Read CSR details
req -text -noout -verify -in ing.com.csr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment