What is the PFX file format?
.pfx files are associated with the PKCS #12 cryptography standard, originally developed by RSA Laboratories and now governed by RFC 7292.
Files with the .pfx extension store encrypted and digitally signed cryptographic objects in a binary DER-encoded container. Each .pfx file is divided into so-called SafeBags, which can also be independently encrypted and signed. The PKCS #12 standard further divides SafeBags into types suitable for storing private keys, X.509 certificates, certificate chains, and other security data.
.pfx is most commonly used to bundle a private key together with its matching certificate chain in a single password-protected file. Typical uses include exporting TLS/SSL certificates between servers, distributing code-signing identities, and transferring S/MIME credentials between devices.
.pfx and .p12 are functionally identical - Windows tools use .pfx while macOS and Linux prefer .p12. Both can be converted to .pem text format with the openssl pkcs12 command. Unlike standalone .cer certificates, a .pfx file carries the private key alongside the certificate, making it the preferred format when the key must travel with the cert.
Security & safety
RISK: HIGHA PFX contains a PRIVATE KEY, so it is one of the most sensitive file types a user handles: anyone with the file and its password can impersonate the certificate's owner - sign code or documents as them, or stand up a server with their TLS identity. Never email a PFX unprotected, never commit it to source control, use a strong export password, and store it securely (ideally delete the file after importing). Treat an unexpected .pfx attachment as suspicious. Only generate/handle PFX files with trusted tools (OS wizards, OpenSSL) - not random "certificate viewer" websites, which could exfiltrate your key and password.
Format details
in a nutshellPrograms that open PFX files
Technical details
deep spec| Container encoding | Binary DER (Distinguished Encoding Rules) over ASN.1; the file is not human-readable without a dedicated parser |
| MIME type | application/x-pkcs12 |
| Magic bytes | 30 82 at offset 0 (ASN.1 DER SEQUENCE with 2-byte length); shared with other DER-encoded formats - identify by extension or MIME type, not bytes alone |
| Internal structure | Nested layers: PFX → AuthenticatedSafe → SafeContents → SafeBags; each SafeBag holds one typed cryptographic object |
| SafeBag types | KeyBag, PKCS8ShroudedKeyBag, CertBag, CRLBag, SecretBag, SafeContents - the six official SafeBag types defined in RFC 7292 |
| Password protection | The overall archive and individual SafeBags can each be encrypted independently with a user-chosen passphrase via password-based encryption |
| Encryption algorithms | AES-256-CBC and 3DES-CBC for modern stacks; RC2 and RC4 appear in legacy files (deprecated - avoid when generating new archives) |
| MAC integrity | An HMAC (SHA-1 in legacy; SHA-256 or SHA-384 in modern implementations) covers the AuthenticatedSafe structure to detect tampering |
| Key derivation | PBKDF1 (RFC 7292 Appendix B) or PBKDF2 with configurable iteration count hardens password-based encryption against brute-force attacks |
| Windows vs. IETF name | .pfx is the original Microsoft-coined suffix; .p12 is the IETF-standard name; the two are byte-for-byte identical and fully interchangeable |
| Multi-object storage | A single .pfx can contain multiple certificates and keys - for example, a full chain of leaf, intermediate, and root CA certificates plus the private key |
| Common CLI conversion | openssl pkcs12 -in file.pfx -out file.pem -nodes extracts to PEM text; openssl pkcs12 -export -out file.pfx bundles PEM inputs into a new archive |
| Platform support | Native on Windows (Certificate Import Wizard, certutil, PowerShell), macOS (Keychain Access), iOS, Android, Java (keytool), and most TLS libraries |
| Typical use cases | Deploying TLS/SSL server certificates, code-signing identities, S/MIME email keys, VPN client credentials, and smart-card provisioning |
| Released | PKCS #12 v1.0 published 1999 by RSA; Microsoft .pfx predates and feeds into it |
| Open standard | Yes · royalty-free |
| Specification | www.rfc-editor.org |