brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: openssl pkcs12 -legacy opens an old .pfx that OpenSSL 3 refuses

Openssl
~/tips/tip-openssl-pkcs12-legacy-old-pfx

openssl pkcs12 -legacy -in old.pfx -nokeys

Loads the legacy provider so OpenSSL 3 can read a .pfx made with RC2 or 3DES.

An old .pfx file and OpenSSL 3 don’t always get along. The error is long and talks about digital envelope routines, which is not a phrase that tells you what to do.

openssl pkcs12 -legacy -in old.pfx -nokeys

The docs say that without -legacy the legacy provider is not loaded. With it, OpenSSL loads that provider automatically. With an old style file made by openssl pkcs12 -export -legacy, reading it with OpenSSL 3.0.13 without the flag stops with an unsupported error that named the algorithm RC2-40-CBC. Adding -legacy prints the certificate straight away.

To see what a file uses, add -info:

openssl pkcs12 -legacy -in old.pfx -info -noout

For such a file that lists pbeWithSHA1And40BitRC2-CBC for the certificate and pbeWithSHA1And3-KeyTripleDES-CBC for the key.

I’d use this as a way out of the old file. Read it once with -legacy, and write a new .pfx without the flag. The docs say the non-legacy default for both certificates and keys is AES-256-CBC with PBKDF2, while the legacy mode uses RC2 or 3DES.

Caveat: the flag only changes what OpenSSL can read. It does not make the old algorithms any stronger, so don’t keep creating new files with it unless some old device or tool really demands it.

Further reading: openssl-pkcs12 documentation

More Openssl tips openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/null | openssl x509 -noout -subject openssl x509 -in cert.pem -days 365 -signkey key.pem -out cert-new.pem printf %s hello | openssl dgst -sha256 -hmac secret echo 'aGVsbG8gd29ybGQ=' | openssl base64 -d | openssl s_client -connect example.com:443 -servername example.com -quiet -keylogfile keys.log All Openssl tips (34) All topics

Link