Certificate Conversion

Convert certificates and private keys between formats for use with Bindplane collectors.

triangle-exclamation

When Conversion is Needed

Format Identification

You need to convert if:

  1. Binary/unreadable files - DER format certificates or keys

  2. .p12 or .pfx files - PKCS#12/PFX bundle files (common on Windows)

  3. Encrypted private keys - Keys with password protection

  4. 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

Bindplane Requirements Recap

Requirement
Status

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:

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 .pfx file)

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 .pfx file)

  • PEM pass phrase (new password for the extracted key)

Step 2: Decrypt the private key

circle-exclamation

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:

  1. Open certmgr.msc (Certificate Manager)

  2. Navigate to the certificate

  3. Right-click → All Tasks → Export

  4. Export as .pfx with private key

  5. Use 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

circle-exclamation

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-----

circle-info

Note: Both PKCS#1 and PKCS#8 formats are supported by Bindplane collectors. This conversion is only needed if you have specific format requirements.

Certificate Chain Assembly

Concatenating Certificates

Create a full certificate chain by concatenating individual certificates:

Correct order:

  1. Server/leaf certificate (first)

  2. Intermediate CA certificate(s)

  3. 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:

circle-exclamation

Conversion Troubleshooting

Issue: "unable to load certificate" or "unable to load private key"

Cause: Wrong input format specified.

Solution:

  • Verify the input format with file command or head

  • Try different -inform options (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 -clcerts to get only the client certificate

  • Verify certificate and key match using verification commands

Last updated

Was this helpful?