0

I need to convert a private key and a cert to a .p12 file. I got a valid certificate, which is also correct formatted. I got the openssl v1.1.1s.

server.crt

-----BEGIN CERTIFICATE-----
THE CERT
-----END CERTIFICATE-----

server.key

-----BEGIN RSA PRIVATE KEY-----
The Private Key
-----END RSA PRIVATE KEY-----

I tried to run this openssl command:

openssl pkcs12 -export -in server.crt -inkey server.key -out certificate.p12

And got this error:

unable to load certificates
Lesmo
  • 19
  • 6
  • No it doesn't. Different Version openssl version used. Different result – Lesmo Jan 03 '23 at 18:41
  • There is something wrong with the certificate. Check with `openssl x509 -in server.crt -text` and you'll likely run into the same error. Make sure that the certificate file is plain ASCII, specifically no UTF-8 BOM at the beginning. When you have still problems and if `openssl x509` fails too please include the full output of it into your question, i.e. all error messages which show up not just the first line. – Steffen Ullrich Jan 03 '23 at 18:53
  • When i'm doing `openssl x509 -in server.crt -text` I get: `unable to load certificate 20764:error:0909006C:PEM routines:get_name:no start line:crypto\pem\pem_lib.c:745:Expecting: TRUSTED CERTIFICATE` – Lesmo Jan 03 '23 at 18:57
  • I'm assuming that you are using Windows and have the file stored in the wrong encoding. See the linked question an specifically the answers which are about encoding, like *"I had the same issue using Windows, got if fixed by opening it in Notepad++ and changing the encoding from "UCS-2 LE BOM" to "UTF-8""*. Make sure to do the same with the private key too in case you get another error loading the key. – Steffen Ullrich Jan 03 '23 at 19:09

0 Answers0