

Check PEM File Certificate Expiration Date openssl x509 -noout -in certificate.pem -dates

If you are responsible for ensuring OpenSSL is secure then probably one of the first things you got to do is to verify the version. This is very handy to validate the protocol, cipher, and cert details. I use this quite often to validate the SSL certificate of a particular URL from the server. Test SSL certificate of particular URL openssl s_client -connect :443 –showcerts If you wish to use existing pkcs12 format with Apache or just in pem format, this will be useful. Convert PKCS12 format to PEM certificate openssl pkcs12 –in cert.p12 –out cert.pem The above command will help you to see the contents of the PKCS12 file. PKCS12 is a binary format so you won’t be able to view the content in notepad or another editor. Check contents of PKCS12 format cert openssl pkcs12 –info –nodes –in cert.p12 If you don’t want to create a new private key instead of using an existing one, you can go with the above command. openssl pkcs12 –export –out sslcert.pfx –inkey key.pem –in sslcert.pem -chain cacert.pem Create CSR using an existing private key openssl req –out certificate.csr –key existing.key –new Tip: you can also include chain certificate by passing –chain as below. If you need to use a cert with the java application or with any other who accept only PKCS#12 format, you can use the above command, which will generate single pfx containing certificate & key file. der Convert Certificate and Private Key to PKCS#12 format openssl pkcs12 –export –out sslcert.pfx –inkey key.pem –in sslcert.pem Convert PEM to DER format openssl x509 –outform der –in sslcert.pem –out r pem format then the above command will help you. der format, and if you need to use them in apache or. Usually, the certificate authority will give you SSL cert in. Check Hash Value of A Certificate openssl x509 -noout -hash -in bestflare.pem Convert DER to PEM format openssl x509 –inform der –in r –out sslcert.pem Verify the Certificate Signer Authority openssl x509 -in certfile.pem -noout -issuer -issuer_hashĬertificate issuer authority signs every certificate and in case you need to check them. then you can use an above command which will give you certificate details. If you would like to validate certificate data like CN, OU, etc. Verify Certificate File openssl x509 -in certfile.pem -text –noout If you doubt your key file, you can use the above command to check. Verify Private Key openssl rsa -in certkey.key –check If you are annoyed with entering a password, then you can use the above openssl rsa -in geekflare.key -check to remove the passphrase key from an existing key. If you are using passphrase in key file and using Apache then every time you start, you have to enter the password. Remove Passphrase from Key openssl rsa -in certkey.key -out nopassphrase.key I have included 2048 for stronger encryption. If you just need to generate RSA private key, you can use the above command. Create RSA Private Key openssl genrsa -out private.key 2048
Openssl command verification#
Verification is essential to ensure you are sending CSR to issuer authority with the required details. openssl req -x509 -sha256 -nodes -days 730 -newkey rsa:2048 -keyout gfselfsigned.key -out gfcert.pem Verify CSR file openssl req -noout -text -in geekflare.csr Tip: by default, it will generate a self-signed certificate valid for only one month so you may consider defining –days parameter to extend the validity.Įx: to have self-signed valid for two years. I have also included sha256 as it’s considered most secure at the moment. The above command will generate a self-signed certificate and key file with 2048-bit RSA. Create a Self-Signed Certificate openssl req -x509 -sha256 -nodes -newkey rsa:2048 -keyout gfselfsigned.key -out gfcert.pem If you intend to use this certificate in Apache or Nginx, then you need to send this CSR file to certificate issuer authority, and they will give you a signed certificate mostly in der or pem format which you need to configure in Apache or Nginx web server. The above command will generate CSR and a 2048-bit RSA key file. Create a new Private Key and Certificate Signing Request openssl req -out geekflare.csr -newkey rsa:2048 -nodes -keyout geekflare.key Note: SSL/TLS operation course would be helpful if you are not familiar with the terms.
