Cloudflare PFX Certificate Generation Guide¶
Complete guide for generating PFX certificates from Cloudflare Origin Certificates for use with Azure Container Apps custom domains.
Table of Contents¶
- Prerequisites
- Step 1: Install OpenSSL on Windows
- Step 2: Generate Cloudflare Origin Certificate
- Step 3: Save Certificate Files
- Step 4: Convert to PFX Format
- Step 5: Verify PFX File
- Step 6: Secure Certificates in 1Password
- Step 7: Upload to Azure Container App
- Troubleshooting
Prerequisites¶
- Active Cloudflare account with domain configured
- Azure subscription with Container App deployed
- Windows 10/11 with Command Prompt or PowerShell
- OpenSSL installed (see Step 1)
- 1Password account (for secure certificate storage)
Step 1: Install OpenSSL on Windows¶
Using Chocolatey package manager:
# Install OpenSSL
choco install openssl
# Restart your terminal and verify installation
openssl version
Note: If you don't have Chocolatey installed, visit https://chocolatey.org/install for installation instructions.
Step 2: Generate Cloudflare Origin Certificate¶
- Log in to your Cloudflare Dashboard: https://dash.cloudflare.com
- Select your domain
- Navigate to SSL/TLS → Origin Server
- Click Create Certificate
- Configure certificate settings:
- Private key type: RSA (2048)
- Certificate validity: 15 years (recommended)
- Hostnames: Enter your domains
- Example:
yourdomain.comand*.yourdomain.com - Or specific subdomains:
app.yourdomain.com
- Example:
- Click Create
Step 3: Save Certificate Files¶
After generating the certificate, you'll see two text blocks:
Save Origin Certificate¶
- Copy the entire Origin Certificate content (including BEGIN/END lines)
- Save as
certificate.pemin a secure location (e.g.,C:\Users\YourUsername\certificates\)
Example certificate.pem:
-----BEGIN CERTIFICATE-----
MIIEpDCCAowCCQDxxx...
(multiple lines)
...xxxxx
-----END CERTIFICATE-----
Save Private Key¶
- Copy the entire Private Key content (including BEGIN/END lines)
- Save as
privatekey.pemin the same location
Example privatekey.pem:
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASC...
(multiple lines)
...xxxxx
-----END PRIVATE KEY-----
Important: Keep the private key secure and never commit it to version control.
Step 4: Convert to PFX Format¶
Azure Container Apps require certificates in PFX/PKCS12 format with a password.
Navigate to Certificate Directory¶
Convert PEM to PFX¶
Set Export Password¶
You'll be prompted to enter a password:
Enter Export Password: [enter a strong password]
Verifying - Enter Export Password: [re-enter the same password]
Important: Remember this password - you'll need it when uploading to Azure.
Expected Output¶
C:\Users\YourUsername\certificates\
├── certificate.pem
├── privatekey.pem
└── certificate.pfx ← Generated file
Step 5: Verify PFX File¶
Verify the PFX file was created successfully:
# Check file exists
dir certificate.pfx
# Verify PFX structure (optional)
openssl pkcs12 -info -in certificate.pfx -noout
You'll be prompted for the password you set earlier. If successful, you'll see certificate information.
Step 6: Secure Certificates in 1Password¶
Before uploading to Azure, securely store your certificates and credentials in 1Password for safekeeping and team access.
Create a New Item in 1Password¶
- Open 1Password application or browser extension
- Click New Item (+ button)
- Select Secure Note or Document type
Save Certificate Files¶
Option A: As Secure Note (Recommended for Text)
- Title:
[Domain] Cloudflare Certificate - [Date] -
Example:
app.yourdomain.com Cloudflare Certificate - 2026-04-15 -
Add the following fields:
- Domain:
app.yourdomain.com - Certificate Type:
Cloudflare Origin Certificate - Valid Until:
2041-04-15(based on 15-year validity) - PFX Password: [Enter the password you created in Step 4]
- Certificate PEM: [Paste contents of certificate.pem]
- Private Key PEM: [Paste contents of privatekey.pem]
- Azure Resource Group:
your-resource-group - Azure Container App:
your-container-app-name -
Created Date:
2026-04-15 -
Add Tags:
certificate,cloudflare,azure,ssl -
Click Save
Option B: As Document Attachment
-
Title:
[Domain] Cloudflare Certificate Files - [Date] -
Attach Files:
- Click Add Files
- Attach
certificate.pem - Attach
privatekey.pem -
Attach
certificate.pfx -
Add Fields:
- Domain:
app.yourdomain.com - PFX Password: [Enter the password]
- Valid Until:
2041-04-15 - Azure Resource Group:
your-resource-group -
Azure Container App:
your-container-app-name -
Add Notes:
-
Click Save
Set Expiration Reminder¶
- In the 1Password item, scroll to Expiration Date or Custom Fields
- Add field: Expiration Date =
2041-04-15 - 1Password will remind you before expiration
Share with Team (Optional)¶
If working in a team:
- Move the item to a Shared Vault (e.g., "Azure Certificates")
- Grant access to relevant team members
- Set appropriate permissions (view/edit)
Delete Local Files¶
After securing in 1Password:
# Navigate to certificate directory
cd C:\Users\YourUsername\certificates
# Securely delete local files (Windows)
del certificate.pem
del privatekey.pem
del certificate.pfx
Important: Only delete local files after confirming they're safely stored in 1Password!
Step 7: Upload to Azure Container App¶
Option A: Azure Portal¶
- Navigate to Azure Portal: https://portal.azure.com
- Go to your Container App
- Select Custom domains (under Settings)
- Click + Add custom domain
- Enter your domain name (e.g.,
app.yourdomain.com) - Choose Upload certificate
- Upload
certificate.pfx(retrieve from 1Password if needed) - Enter the password you set in Step 4 (retrieve from 1Password)
- Click Add
Option B: Azure CLI¶
# Upload certificate
az containerapp ssl upload \
--resource-group <your-resource-group> \
--name <your-container-app-name> \
--environment <your-environment-name> \
--hostname <your-domain.com> \
--certificate-file certificate.pfx \
--password <your-pfx-password>
Replace placeholders:
- <your-resource-group>: Your Azure resource group name
- <your-container-app-name>: Your container app name
- <your-environment-name>: Your container app environment name
- <your-domain.com>: Your custom domain (e.g., app.yourdomain.com)
- <your-pfx-password>: The password you set in Step 4 (retrieve from 1Password)
Configure DNS in Cloudflare¶
After uploading the certificate, configure DNS:
- In Cloudflare Dashboard, go to DNS → Records
- Add CNAME record:
- Type: CNAME
- Name: Your subdomain (e.g.,
app) - Target: Your Azure Container App default domain
- Example:
your-app.nicegrass-12345.eastus.azurecontainerapps.io
- Example:
- Proxy status: Proxied (orange cloud) - ENABLED
-
TTL: Auto
-
Configure SSL/TLS settings:
- Go to SSL/TLS → Overview
- Set encryption mode to Full (strict)
Verify Setup¶
- Wait 5-15 minutes for DNS propagation
- Test your domain:
# Check DNS resolution
nslookup app.yourdomain.com
# Test HTTPS connection
curl -I https://app.yourdomain.com
Expected response: HTTP/2 200 or your application's response.
Troubleshooting¶
OpenSSL Not Recognized¶
Error:
Solution:
1. Reinstall OpenSSL using Chocolatey (see Step 1)
2. Restart your terminal/command prompt
3. Verify installation: openssl version
Certificate Validation Failed in Azure¶
Error: "Certificate validation failed" or "Invalid certificate"
Solutions: - Verify PFX includes both certificate and private key - Check certificate expiration date - Ensure password is correct - Regenerate PFX if needed
DNS Not Resolving¶
Error: Domain doesn't resolve to Azure Container App
Solutions:
- Wait 15-30 minutes for DNS propagation
- Verify CNAME record points to correct Azure domain
- Check if Cloudflare proxy is enabled (orange cloud)
- Use nslookup or dig to verify DNS
SSL/TLS Errors¶
Error: "SSL handshake failed" or "Certificate mismatch"
Solutions: - In Cloudflare, set SSL/TLS mode to Full (strict) - Verify certificate includes your domain name - Check certificate hasn't expired - Ensure Cloudflare proxy is enabled
Azure CLI Errors¶
Error: "The term 'az' is not recognized"
Solution: Install Azure CLI: https://aka.ms/installazurecliwindows
Security Best Practices¶
- Store certificates in 1Password
- Follow Step 6 to securely store all certificates and passwords
- Use 1Password's secure sharing for team access
-
Set expiration reminders in 1Password
-
Never commit certificates to version control
- Add to
.gitignore:*.pem,*.pfx,*.key -
Never commit passwords or sensitive data
-
Use strong passwords
- PFX password should be 16+ characters
- Use 1Password's password generator
-
Store in 1Password, not in plain text files
-
Rotate certificates regularly
- Set reminder before 15-year expiration
- Consider shorter validity periods for higher security
-
Update 1Password entry when rotating
-
Delete local copies after securing
- Once stored in 1Password and uploaded to Azure, securely delete local files
- Only retrieve from 1Password when needed
- Never leave certificates in Downloads or Desktop folders
Certificate Renewal Process¶
Cloudflare Origin Certificates are valid for up to 15 years. When renewal is needed:
- Generate new certificate in Cloudflare (repeat Step 2)
- Save new certificate files (repeat Step 3)
- Generate new PFX (repeat Step 4)
- Verify new PFX (repeat Step 5)
- Update 1Password entry with new certificate files and expiration date
- Upload new certificate to Azure Container App (Step 7)
- Azure will automatically switch to new certificate
- Revoke old certificate in Cloudflare
- Archive or delete old 1Password entry
Useful Commands Reference¶
# Install OpenSSL
choco install openssl
# Verify OpenSSL version
openssl version
# Convert PEM to PFX
openssl pkcs12 -export -out certificate.pfx -inkey privatekey.pem -in certificate.pem
# Verify PFX file
openssl pkcs12 -info -in certificate.pfx -noout
# Check DNS
nslookup yourdomain.com
# Test HTTPS
curl -I https://yourdomain.com
# Azure CLI - Upload certificate (retrieve password from 1Password)
az containerapp ssl upload \
--resource-group <rg> \
--name <app> \
--environment <env> \
--hostname <domain> \
--certificate-file certificate.pfx \
--password <password-from-1password>
# Delete local certificate files (after securing in 1Password)
del certificate.pem
del privatekey.pem
del certificate.pfx
Additional Resources¶
- Cloudflare Origin Certificates: https://developers.cloudflare.com/ssl/origin-configuration/origin-ca
- Azure Container Apps Custom Domains: https://learn.microsoft.com/azure/container-apps/custom-domains-managed-certificates
- OpenSSL Documentation: https://www.openssl.org/docs/
- Azure CLI Reference: https://learn.microsoft.com/cli/azure/containerapp
- 1Password Documentation: https://support.1password.com/
- 1Password for Teams: https://support.1password.com/teams-getting-started/
Support¶
For issues related to: - Cloudflare: https://support.cloudflare.com - Azure Container Apps: https://learn.microsoft.com/azure/container-apps/ - OpenSSL: https://www.openssl.org/community/
Last Updated: 2026-04-15 Version: 1.0.0