SHA2 certificate OpenSSL Linux

To generate a certificate signing request with requesting a SHA256 signed certificate you can run the following script on a linux box with OpenSSL installed on it. Run this Shell script. chmod +X of course

 

domein=YourFQDN
pass=YourPassword
organisatie=YourOrganisation
provincie=YourProvince
stad=YourCity

string=/CN=$domein/O=$organisatie/C=NL/ST=$provincie/L=$stad
openssl genrsa -des3 -passout pass:$pass 2048 > $domein.key
openssl req -sha256 -new -key $domein.key -passin pass:$pass -subj $string -out $domein.csr
openssl rsa -in $domein.key -passin pass:$pass -out $domein-decrypted.key

~

This script will output a private key, a decrypted private key and a CSR.

If you received the CA’s response and it is in a wrong format you can run all of the lines below. If you received a PEM formatted response you can just the line with PKCS12 OpenSSL command.

 

domein=YourFQDN
pass=YourPassword

openssl x509 -in $domein.cer  -out $domein.der -outform DER
openssl x509 -in $domein.der -inform DER -out $domein.pem -outform PEM
openssl pkcs12 -export -in $domein.pem -inkey $domein.key -passin pass:$pass -out $domein.pfx -passout pass:$pass -name $domein