OpenSSL Common Usage

Search for a command to run...

No comments yet. Be the first to comment.
Most AI agents that support scheduled tasks have two sources of instruction when a cron job fires: The cron prompt — the task-specific instructions you wrote when scheduling the job The skill — a re

TL;DR Scarp draw result, host on GitHub, retrieve it like API at damacai.hongineer.com. Data Scraping I have previously shared a technique for scraping Da Ma Cai draw result. Now I finally have time t

This is a Bash script that check if the replica (slave) health status. If there is an issue, it will exist with non-zero status. This is useful when used with monitoring tools like [Monit](https://mmo

chmod is a command-line utility used to change the access permissions of file system objects such as files and directories. It allows you to control who can read, write, and execute those objects. Changing Permissions Using Octal Notation Example Usa...
chown changes the ownership of files and directories. This involves modifying the user and/or group associated with a file, determining who has access and permissions. Changing File Ownership to a Specific User Example Usage: chown user file.txt What...
On this page
OpenSSL is a powerful Linux command for managing certificates. These are some common operations I frequently use.
This command generates a 2048 bits private key.
openssl genrsa -out example.key 2048
Verify private and public key by comparing the output of the following 2 commands.
ssh-keygen -yef id_rsa
ssh-keygen -yef id_rsa.pub
CSR is generated from existing private key. Make sure you keep your private key well.
openssl req -out example.csr -key example.key -new
Generate a new private key and new CSR using that key.
openssl req -new -newkey rsa:2048 -nodes -keyout example.key -out example.csr
openssl req -in example.csr -noout -text
Both private key and CSR are needed to generate SSL cert. Choose an appropriate expiry date for your cert.
openssl x509 -req -days 3650 -in example.csr -signkey example.key -out example.crt
Note that the CA bundle file is needed for the certfile switch. certfile switch is optional.
openssl pkcs12 -export -out example.pfx -inkey example.key -in example.crt -certfile CACert.crt
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.pem
This is referring to x509 certs, which is used by Apache for SSL.
openssl x509 -in example.crt -text
View a certificate encoded in PKCS#7 format
openssl pkcs7 -print_certs -in example.p7b
View a certificate and key pair encoded in PKCS#12 format
openssl pkcs12 -info -in example.pfx
RSA private key is used to generate CSR and cert. Verification can be performed by matching modulus that is embedded in key, CSR, and cert.
Get hashed modulus of key
openssl rsa -in example.key -noout -modulus | md5sum
If you are getting "unable to load private key" issue, and the first line in key file is -----BEGIN OPENSSH PRIVATE KEY----- instead of -----BEGIN RSA PRIVATE KEY-----, there is a workaround. Use the following command to convert it to regular REM format.
ssh-keygen -p -m PEM -f example.key
Get hashed modulus of CSR
openssl req -in example.csr -noout -modulus | md5sum
Get hashed modulus of cert
openssl x509 -in example.crt -noout -modulus | md5sum