how to bundle key and certificate together into one p12 certificate

Nikola Mandic
1 min readJul 8, 2019


You might want to bundle certificate and private key together to be able to sign things and googling takes bit more than expected. Here is rundown at one place

Lets generate key for certificate by running following

openssl genrsa -out mysite.key 2048

Lets obtain signing request with this new key just generated

openssl req -new -sha256 -key mysite.key -out mysite.csr

Now to be able to have it in p12 format we should convert certificate we got from signing authority to PEM

openssl x509 -inform DER -in mysite.crt -out mysite.pem -outform PEM

Now to tie key and certificate together into one certificate that one can use to sign things

openssl pkcs12 -export -clcerts -inkey mysite.key -in mysite.pem -out mysite.p12 -name “My Site”

enjoy :-)