Create p12 from a .pem with only a private key

Hubert Kario hkario at redhat.com
Tue Mar 17 11:01:56 UTC 2020


On Thursday, 20 February 2020 09:35:56 CET, Estefania wrote:
> I do not know if I explained well, i have a .pem with a private key inside
> like this.
>
> -----BEGIN PRIVATE KEY-----
> masdfasdfasdfasdfasdfasdfasdff
> asdfasdfasdfasdfasdfasdfasdfasf
> asdfasfasdfasdfasdfasdfasdfasdf
> -----END PRIVATE KEY-----
>
>
> and i need to convert it to .p12
>
> do i need a certificate aswell?

technically, no, the standard allows for storing just the key in the 
PKCS#12
file

that being said, I can imagine many implementations tripping over such 
files

if you have a private key in "localhost.key" you can convert it to a 
PKCS#12
file using the following command:

openssl pkcs12 -export -out file.p12 -inkey localhost.key -nocerts -keypbe 
aes-128-cbc -passout pass:password

> I have tried what you suggest:
> $ openssl req -x509 -subj /CN=foo -keyout /dev/null -nodes | openssl pkcs12
> -out x.p12 -export -nokeys
> Generating a 2048 bit RSA private key
> ................+++
> .+++
> writing new private key to 'nul'
> -----
> Subject does not start with '/'.
> problems making Certificate Request
> unable to load certificates
>
> Thanks!
>
>
>
>
>
> --
> Sent from: http://openssl.6102.n7.nabble.com/OpenSSL-User-f3.html
>
>
>

-- 
Regards,
Hubert Kario
Senior Quality Engineer, QE BaseOS Security team
Web: www.cz.redhat.com
Red Hat Czech s.r.o., Purkyňova 115, 612 00  Brno, Czech Republic



More information about the openssl-users mailing list