Digital Certificates Flow

2025.02.24 · 1 minute read

Understanding Digital Certificates

Digital certificates serve three crucial purposes: proving your identity, enabling secure communication, and preventing identity theft.

Here’s how the certification process works:

  1. Generate your unique cryptographic keys (private and public)
  2. Complete an identity verification application
  3. Get your application validated by a trusted third party
  4. Securely store your credentials together

Using these digital credentials involves:

  1. Creating a digital signature with your private key
  2. Having others verify your signature using your public key
  3. Allowing third parties to authenticate your identity

The Certification Process

Getting a digital certificate involves four main steps:

  1. Creating Your Key Pair
  • Generate a private key (must remain secret)
  • Create its matching public key
  1. Applying for Certification
  • Compile your identification details
  • Create a Certificate Signing Request (CSR)
  1. CA Verification
  • Submit to a Certificate Authority (CA)
  • Receive your verified certificate
  1. Setting Up Your Certificate
  • Combine your private key with the certificate
  • Store everything securely

Technical Implementation

The process begins with creating a P12 file (PKCS#12 format), which serves as a secure container for:

  • Your private key
  • Your certificate (once issued)
  • The certificate chain (once established)
keytool -genkeypair \
    -keysize 4096 \
    -keystore keystore_file.p12 \
    -storetype PKCS12 \
    -alias keystore_file \
    -dname "CN=keystore_file,OU=dataproxy-services" \
    -keyalg RSA \
    -storepass abc

The generated p12 file itself is a type of keystore that can be directly used as a CSR (Certificate Signing Request):

keytool -certreq \
    -keystore keystore_file.p12 \
    -alias keystore_file \
    -file certificate.csr \
    -storepass abc

After the CA verifies and signs your request, you’ll need to merge the original p12 containing the private key to complete the certificate installation:

keytool -importcert \
    -keystore keystore_file.p12 \
    -file certificate.p7b \
    -alias keystore_file \
    -trustcacerts \
    -noprompt \
    -storepass abca

Usage

For practical use, I recommend integrating P12 with Vault for enhanced security. Since P12 files are binary and not transmission-friendly, we first convert them to base64 format:

base64 -i keystore_file.p12 -o p12.base64

Vault includes encrypted storage functionality, and kv is suitable for storing certificate-type data. We store this file in Vault:

vault kv put custom/internal/certificates/kafkaKeyStore [email protected]

Finally, configure your application to use the certificate:

jks:
  secretList:
    - name: kafkaStore
      vaultPath: "custom/internal/certificates/kafkaKeyStore"

This setup allows your application to automatically retrieve the certificate at startup, streamlining the secure authentication process.

Thank you for reading! Your support is appreciated.

If you enjoyed this, consider buying me a coffee. ☕️