openssl: changing the private key of a PKCS12
Translation of the original in Catalan. Read it in: CatalàCastellano
For those to whom PKCS12 la wikipedia sounds like nothing, it's a good place to learn what it's about, a rough definition of what a PKCS12 contains would be:
-
CA cert (Certificate Authority)
-
Client cert
-
Client private key
This allows quickly configuring clients that have to use certificates since we only have one file to put in the configuration.
Below I paste a small cookbook that explains how to change or remove the symmetric key that protects the private key of the client certificate:
#extreiem private key d'un p12
openssl pkcs12 -in client.p12 -nocerts -out client_private_key.pem
#extreiem client certificate d'una p12
openssl pkcs12 -in client.p12 -clcerts -nokeys -out client_cert.pem
#extreiem CA d'una p12
openssl pkcs12 -in client.p12 -cacerts -nokeys -out ca_cert.pem
#treiem password d'una clau
openssl rsa -in client_private_key.pem -out client_private_key.nopass.pem
#canvi pass d'una clau
openssl rsa -in client_private_key.pem -des3 -out client_private_key.novaclau.pem
#creem una p12 a partir dels seus fitxers arrel
openssl pkcs12 -export -out client.nou.p12 -in client_cert.pem -inkey client_private_key.novaclau.pem -certfile ca_cert.pem -name "nova clau" -out client.nou.p12