Certificate Conversion
Convert certificates and private keys between formats for use with Bindplane collectors.
When Conversion is Needed
Format Identification
You need to convert if:
Binary/unreadable files - DER format certificates or keys
.p12or.pfxfiles - PKCS#12/PFX bundle files (common on Windows)Encrypted private keys - Keys with password protection
Wrong key format - PKCS#1 vs PKCS#8 (though both are supported)
How to identify your file format:
# View the file
head -n 5 certificate.crt
# If you see this → PEM format
# -----BEGIN CERTIFICATE-----
# If you see binary gibberish → DER format
# If you have .p12 or .pfx extension → PKCS#12 bundle# View the file
Get-Content C:\certs\certificate.crt -First 5
# If you see this → PEM format
# -----BEGIN CERTIFICATE-----
# If you see binary gibberish → DER format
# If you have .p12 or .pfx extension → PKCS#12 bundleBindplane Requirements Recap
PEM format
SUPPORTED (Base64-encoded text)
DER format
NOT supported
PKCS#12/PFX
NOT supported (must extract)
Private key encryption
NOT supported (must decrypt)
DER to PEM Conversion
DER is a binary encoding format. Bindplane requires PEM (text-based).
Convert DER Certificate to PEM
Verify the conversion:
Convert DER Private Key to PEM
For RSA keys:
For ECDSA keys:
For generic private keys:
Platform-Specific Notes
Linux/macOS:
OpenSSL is usually pre-installed
Commands work as shown above
Windows:
Install OpenSSL from: https://slproweb.com/products/Win32OpenSSL.html
Or use Windows Subsystem for Linux (WSL)
Or use Git Bash which includes OpenSSL
PKCS#12/PFX to PEM Conversion
PKCS#12 (.p12) and PFX (.pfx) are bundle formats that contain certificates and private keys together, often used on Windows.
Extract Certificate from PKCS#12/PFX
Flags explained:
-clcerts: Extract only client certificates (not CA certs)-nokeys: Don't extract private keys
You'll be prompted for:
Import password (the password protecting the
.pfxfile)
Extract Private Key from PKCS#12/PFX
Step 1: Extract encrypted key
Flags explained:
-nocerts: Don't extract certificates
You'll be prompted for:
Import password (the password protecting the
.pfxfile)PEM pass phrase (new password for the extracted key)
Step 2: Decrypt the private key
You'll be prompted for:
The PEM pass phrase you set in Step 1
Secure the decrypted key:
Extract CA Certificates from PKCS#12/PFX
If your .pfx bundle contains CA certificates:
Flags explained:
-cacerts: Extract only CA certificates-nokeys: Don't extract private keys
Complete PKCS#12/PFX Extraction Example
Extract everything from a .pfx file:
Windows-Specific Considerations
Exporting from Windows Certificate Store:
If your certificate is in the Windows Certificate Store:
Open
certmgr.msc(Certificate Manager)Navigate to the certificate
Right-click → All Tasks → Export
Export as
.pfxwith private keyUse the extraction commands above
Decrypting Private Keys
Encrypted private keys have password protection and cannot be used with Bindplane collectors.
Identify Encrypted Keys
Decrypt RSA Keys (PKCS#1)
You'll be prompted for:
The passphrase protecting the encrypted key
Decrypt ECDSA Keys
Decrypt Generic Private Keys (PKCS#8)
Works for any key type:
Verify Key is Decrypted
Security Considerations
Secure your decrypted keys:
Key Format Conversion
PKCS#1 to PKCS#8
Convert traditional RSA format to PKCS#8:
Flags:
-topk8: Convert to PKCS#8-nocrypt: Don't encrypt the output key
Result:
Changes header from
-----BEGIN RSA PRIVATE KEY-----To
-----BEGIN PRIVATE KEY-----
PKCS#8 to PKCS#1
Convert PKCS#8 to traditional RSA format:
Result:
Changes header from
-----BEGIN PRIVATE KEY-----To
-----BEGIN RSA PRIVATE KEY-----
Certificate Chain Assembly
Concatenating Certificates
Create a full certificate chain by concatenating individual certificates:
Correct order:
Server/leaf certificate (first)
Intermediate CA certificate(s)
Root CA certificate (optional, last)
Example Chain Assembly
Verify Certificate Order
Check that certificates are in the correct order:
Testing the Chain
Test that clients can verify the full chain:
Generating Test Certificates
For testing and development, you can generate self-signed certificates.
Generate Self-Signed Certificate with OpenSSL
Quick single command:
Flags explained:
-x509: Generate self-signed certificate-newkey rsa:4096: Generate 4096-bit RSA key-keyout key.pem: Output key filename-out cert.pem: Output certificate filename-days 365: Valid for 365 days-nodes: Don't encrypt the private key (no DES)-subj: Certificate subject (customize as needed)
Generate Certificate with Subject Alternative Names (SANs)
Create a config file for SANs:
Generate the certificate:
Generate Certificate Chain for Testing
Create a complete CA chain for testing:
Step 1: Generate Root CA
Step 2: Generate Intermediate CA
Step 3: Generate Server Certificate
Step 4: Create Fullchain
Generate mTLS Test Certificates
Generate client certificates for mTLS testing:
Conversion Troubleshooting
Issue: "unable to load certificate" or "unable to load private key"
Cause: Wrong input format specified.
Solution:
Verify the input format with
filecommand orheadTry different
-informoptions (PEM, DER)Check that the file is not corrupted
Issue: "bad decrypt" when decrypting
Cause: Wrong password or corrupted file.
Solution:
Verify the password is correct
Check the file is not corrupted
Try opening the file with other tools to verify
Issue: "no certificate matches private key"
Cause: Extracted wrong certificate from bundle.
Solution:
Re-extract with
-clcertsto get only the client certificateVerify certificate and key match using verification commands
Last updated
Was this helpful?