Error message when trying to convert private key from a pem-file to a pvk-file

openssl

I'm trying to convert a private key from a pem file/format to a pvk file/format using OpenSSL with the following command:

openssl rsa -in C:\tmp\key.pem -outform PVK -pvk-strong -out C:\tmp\key.pvk

I get the following error message after entering the PEM pass phrase (for test purposes I'm using a 4 letter strong pass phrase as far as I understand 4 characters is minimum):

unable to write key
22164:error:060A6094:digital envelope routines:EVP_DecryptUpdate:invalid operation:crypto\evp\evp_enc.c:451:

Couldn't really find any information on how to resolve the error, any pointers would be appreciated.

Note: the private key was extracted from an pfx file which triggered a warning, please see my other question

Note: there are various guides for this conversion (e.g. this one)

Best Answer

So, have you tried first converting your .pem to a .crt, converting that .crt to .pvk?

Convert .pem to .crt:

openssl x509 -outform der -in your-cert.pem -out your-cert.crt

Convert .crt to .pvk:

openssl pkcs12 -export -out name_of_cert.pfx -inkey name_of_key.key -in 
name_of_cert.crt
Related Question