PKCS#12
PKCS#12, often seen as .pfx or .p12 files, is a format for storing cryptographic objects like private keys and certificates in a single, password-protected file. It’s commonly used for bundling certificates with their corresponding private keys and intermediate certificates, forming a chain of trust.
Here’s a more detailed breakdown:
What it is:
- Archive format:PKCS#12 is a way to package multiple cryptographic items (certificates, private keys, etc.) into a single file.
- Security:It can be password-protected and encrypted, enhancing security for sensitive data like private keys.
- Common Usage:It’s widely used for:
- Bundling a private key with its corresponding certificate (e.g., server certificates).
- Bundling a chain of trust (e.g., root, intermediate, and end-entity certificates).
- Storing client certificates for authentication.
- Interoperability:Unlike formats like JKS (Java KeyStore), PKCS#12 is language-neutral and widely supported by various tools and systems.
Key Features:
- Private Key and Certificate Storage: PKCS#12 files are designed to store both private keys and their associated X.509 certificates.
- Password Protection: The file can be password-protected, adding an extra layer of security.
- Chain of Trust: PKCS#12 files can contain the entire chain of trust for a certificate, including root and intermediate certificates.
- PFX/P12 Extension: You’ll often see PKCS#12 files with the extensions .pfx or .p12.
Common Uses:
- Server Certificates: Storing server certificates (e.g., for HTTPS) along with their private keys.
- Client Certificates: Storing client certificates for authentication purposes.
- Code Signing: Storing code signing certificates and private keys.
- Document Signing: Storing document signing certificates and private keys.
Example Usage (OpenSSL):
To extract a private key from a PKCS#12 file using OpenSSL:
Kod
openssl pkcs12 -in certificate.p12 -nocerts -out private_key.pem -nodes
To extract the certificate(s) from a PKCS#12 file:
Kod
openssl pkcs12 -in certificate.p12 -clcerts -nokeys -out certificate.pem
You’ll be prompted for the password of the PKCS#12 file.