John Sonnino
John Sonnino

Reputation: 579

How do I use OpenSSL in the terminal to convert a .pem file to other formats?

I am trying to use OpenSSL in the terminal. I have installed OpenSSL using brew install openssl. I want to convert a .pem file to another format that my hosting provider will accept.

I have tried several different formulations of the code and plying the certificate from different places but none seem to work and all give me various error messages including permission denied.

This is what I tried last...

openssl pkcs12 -in /Users/myname/fullchain.pem -inkey /Users/myname/privkey.pem -out /Users/myname/fullchain.pfx -cacerts

This is my output

4552226412:error:0DFFF0A8:asn1 encoding routines:CRYPTO_internal:wrong tag:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.250.1/libressl-2.6/crypto/asn1/tasn_dec.c:1125:
4552226412:error:0DFFF03A:asn1 encoding routines:CRYPTO_internal:nested asn1 error:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.250.1/libressl-2.6/crypto/asn1/tasn_dec.c:306:Type=PKCS12

What might this mean and what code should I be using?

Edit: I am getting output files but they are of course empty.

Upvotes: 0

Views: 3380

Answers (1)

markybb41
markybb41

Reputation: 290

That error message is usually when the certificate format you pass to the command is not what it is expecting. The following command should solve it for you.

openssl pkcs12 -export -out  /Users/myname/fullchain.pfx -inkey /Users/myname/privkey.pem -in /Users/myname/fullchain.pem

It should prompt you to enter an export password to encrypt the .pfx files content if it has succeeded.

Upvotes: 1

Related Questions