Scenarios: 4
FFI Functions: ~30
Status: ⏳ Planned
This category encompasses all scenarios for importing and exporting certificates and keys. PEM, PFX/PKCS#12, PKCS#7 and interoperability with other systems.
| ID | Scenario | Description | Complexity | Status |
|---|---|---|---|---|
| 12.1 | PEM Export/Import | Base64-encoded certificates | ⭐⭐ | ⏳ |
| 12.2 | PFX/PKCS#12 | Certificate + Private Key Bundle | ⭐⭐⭐ | ⏳ |
| 12.3 | PKCS#7 Chain | Export certificate chain | ⭐⭐ | ⏳ |
| 12.4 | Interoperability | OpenSSL, Windows, Java | ⭐⭐⭐⭐ | ⏳ |
| Format | Extension | Contains | Encrypted | Usage |
|---|---|---|---|---|
| PEM | .pem, .crt, .key | Single objects | Optional | Linux, OpenSSL |
| DER | .der, .cer | Single objects | No | Binary protocols |
| PFX/PKCS#12 | .pfx, .p12 | Cert + Key + Chain | Yes | Windows, Java |
| PKCS#7 | .p7b, .p7c | Certificate chain | No | Chain distribution |
| JKS | .jks | Java KeyStore | Yes | Java applications |
| From/To | OpenSSL | Windows | Java | .NET |
|---|---|---|---|---|
| OpenSSL | - | PFX | PKCS#7 → JKS | PEM |
| Windows | PFX → PEM | - | PFX | PFX |
| Java | JKS → PEM | JKS → PFX | - | PFX |
| .NET | PEM | PFX | PFX | - |
// Certificate as PEM string certPem = certificate.ToPem(); File.WriteAllText("server.crt.pem", certPem); // Private Key encrypted as PEM string keyPem = privateKey.ToEncryptedPem( password: securePassword, algorithm: EncryptionAlgorithm.Aes256Gcm ); File.WriteAllText("server.key.pem", keyPem);
// Create PFX with certificate, key and chain byte[] pfxData = ctx.ExportToPfx( certificate: serverCert, privateKey: serverKey, chain: new[] { intermediateCert, rootCert }, password: pfxPassword, friendlyName: "Server Certificate" ); File.WriteAllBytes("server.pfx", pfxData);
// Load PFX var (cert, key, chain) = ctx.ImportFromPfx( pfxPath: "server.pfx", password: pfxPassword ); Console.WriteLine($"Certificate: {cert.Subject}"); Console.WriteLine($"Chain length: {chain.Length}");
// Certificate chain as P7B byte[] p7bData = ctx.ExportChainToPkcs7( certificates: new[] { serverCert, intermediateCert, rootCert } ); File.WriteAllBytes("chain.p7b", p7bData);
openssl pkcs12 -export \ -in server.crt.pem \ -inkey server.key.pem \ -certfile chain.pem \ -out server.pfx \ -name "Server Certificate"
# Extract certificate openssl pkcs12 -in server.pfx -clcerts -nokeys -out server.crt.pem # Extract private key openssl pkcs12 -in server.pfx -nocerts -out server.key.pem # Extract chain openssl pkcs12 -in server.pfx -cacerts -nokeys -out chain.pem
openssl x509 -in cert.der -inform DER -out cert.pem -outform PEM
| Category | Relationship |
|---|---|
| 11. Key Management | Export keys |
| 4. Certificate Management | Backup/Restore |
| 10. TLS/mTLS | Deploy certificates |
« ← 11. Key Management | ↑ Scenarios | 🏠 Home → »
Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional