सभी SSL articles SSL और Certificates

SSL Certificate Formats: PEM, PFX, DER explained

SSL certificates और private keys कई file formats में store की जा सकती हैं। Content same होता है — encoding और packaging अलग होती है। ज़्यादातर confusion आपके server के लिए एक specific format की requirement से आता है।

Format comparison

FormatExtensionsEncodingContainsUsed by
PEM.pem, .crt, .cer, .keyBase64 (text)Cert, key, या chain (एक per file)Nginx, Apache, ज़्यादातर Linux servers
DER.der, .cerBinarySingle cert या keyJava, कुछ Windows apps
PFX/PKCS#12.pfx, .p12BinaryCert + key + chain एक file मेंWindows IIS, Azure, macOS Keychain

PEM — सबसे common format

PEM (Privacy Enhanced Mail) base64-encoded text है। आप इसे text editor में open कर सकते हैं:

-----BEGIN CERTIFICATE-----
MIIFYjCCBEqgAwIBAgISA8ht...
(base64 encoded data)
-----END CERTIFICATE-----

PEM files में certificates, private keys, या certificate chains हो सकते हैं। Header बताता है कि अंदर क्या है:

  • BEGIN CERTIFICATE — एक certificate
  • BEGIN PRIVATE KEY — एक private key (या BEGIN RSA PRIVATE KEY / BEGIN EC PRIVATE KEY)
  • BEGIN CERTIFICATE REQUEST — एक CSR

GetHTTPS PEM format में output देता हैprivkey.pem, cert.pem, chain.pem, fullchain.pem

DER — binary encoding

DER same data का binary form है जिसे PEM text के रूप में encode करता है। यह human-readable नहीं है। Mainly Java applications (keytool) और कुछ Windows components द्वारा use किया जाता है।

PFX/PKCS#12 — bundle format

PFX (Personal Information Exchange) certificate, private key, और chain को एक password-protected file में bundle करता है। Windows IIS, Azure App Service, और macOS Keychain को इस format की ज़रूरत होती है।

Formats के बीच conversion

सभी conversions OpenSSL use करते हैं:

PEM → PFX

openssl pkcs12 -export \
  -out certificate.pfx \
  -inkey privkey.pem \
  -in cert.pem \
  -certfile chain.pem

आपसे एक export password set करने के लिए कहा जाएगा।

PFX → PEM

# Extract certificate
openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out cert.pem

# Extract private key
openssl pkcs12 -in certificate.pfx -nocerts -nodes -out privkey.pem

# Extract chain
openssl pkcs12 -in certificate.pfx -cacerts -nokeys -out chain.pem

PEM → DER

openssl x509 -in cert.pem -outform DER -out cert.der

DER → PEM

openssl x509 -in cert.der -inform DER -outform PEM -out cert.pem

मुझे कौन सा format चाहिए?

Server/PlatformFormatRequired files
NginxPEMfullchain.pem + privkey.pem
ApachePEMcert.pem + chain.pem + privkey.pem
IIS (Windows)PFXcertificate.pfx (PEM से convert करें)
Azure App ServicePFXcertificate.pfx
AWS (ACM)PEMcert.pem + chain.pem + privkey.pem (console में paste करें)
Java (Tomcat)JKS या PFXPEM → PFX → JKS keytool से convert करें
Node.jsPEMCode में directly files read करें

File का format कैसे identify करें

Sure नहीं कि file किस format में है? Check करें:

# If it starts with "-----BEGIN" — it's PEM (base64 text)
head -1 mystery-file.pem

# If it's binary (garbled text) — it's DER or PFX
file mystery-file.cer
# Output like "data" or "certificate" = DER
# Output like "PKCS12" = PFX

# Inspect a PEM certificate
openssl x509 -in cert.pem -noout -text

# Inspect a DER certificate
openssl x509 -in cert.der -inform DER -noout -text

# Inspect a PFX file
openssl pkcs12 -in cert.pfx -info -nokeys

Common file extension confusion

ExtensionUsually meansBut could be
.pemPEM (base64)Always PEM
.crtPEM certificateWindows पर DER
.cerPEM certificateWindows पर DER
.keyPEM private keyDER (rare)
.pfxPKCS#12 bundleAlways PFX
.p12PKCS#12 bundleAlways PFX (.pfx के same)
.derDER (binary)Always DER
.jksJava KeyStoreAlways JKS

Thumb rule: File को text editor में open करें। अगर आप -----BEGIN CERTIFICATE----- देखते हैं, तो extension चाहे जो हो, यह PEM है। अगर आप binary garbage देखते हैं, तो यह DER या PFX है।

FAQ

.crt, .cer, और .pem में क्या difference है?

ये सभी PEM format हो सकते हैं। Extension एक naming convention है, format indicator नहीं। .crt और .cer आमतौर पर certificate files के लिए use होते हैं, .pem किसी भी PEM-encoded file के लिए। Windows पर, .cer files कभी-कभी DER-encoded होती हैं — check करने के लिए text editor में open करें।

GetHTTPS मुझे 4 files क्यों देता है?

Maximum compatibility। GetHTTPS provide करता है: privkey.pem (private key), cert.pem (सिर्फ आपका certificate), chain.pem (intermediate CA certificate), fullchain.pem (cert + chain combined)। Nginx को fullchain.pem चाहिए; Apache को अलग cert.pem + chain.pem चाहिए; IIS को PFX चाहिए (PEM से convert करें)।

Windows/IIS के लिए PFX कैसे बनाएँ?

ऊपर दिए गए OpenSSL PEM → PFX command use करें। आपको GetHTTPS से privkey.pem, cert.pem, और chain.pem चाहिए। Resulting .pfx को IIS, Azure App Service, या macOS Keychain में import किया जा सकता है।

क्या मैं private key के बिना एक format से दूसरे में convert कर सकता हूँ?

आप certificate को private key के बिना PEM और DER के बीच convert कर सकते हैं। लेकिन PFX बनाने के लिए private key ज़रूरी है (यह cert + key को एक साथ bundle करता है)। अगर आपने अपनी private key खो दी है, तो आपको एक नया certificate generate करना होगा।

Let’s Encrypt कौन सा format use करता है?

Let’s Encrypt (GetHTTPS सहित किसी भी ACME client के through) PEM format में output देता है। अगर आपको अपने server के लिए different format चाहिए, तो ऊपर दिए गए OpenSSL commands use करके convert करें।

संबंधित लेख

डिप्लॉयमेंट 2026-05-08
Nginx पर SSL Certificate कैसे Install करें
Nginx पर SSL certificate install करने की step-by-step guide। File upload, full server block config, TLS best practices, HTTP/2, HSTS, redirect setup, testing, और 6 common errors का troubleshooting included है।
डिप्लॉयमेंट 2026-05-08
Apache पर SSL Certificate कैसे Install करें
mod_ssl के साथ Apache पर SSL certificate install करने की step-by-step guide। File upload, VirtualHost config, TLS best practices, HSTS, HTTP redirect, और 5 common errors का solution शामिल है।
SSL और Certificates 2026-05-07
CSR (Certificate Signing Request) क्या है?
CSR एक Certificate Authority को SSL certificate request करने के लिए भेजा गया message है। जानें CSR में क्या होता है, इसे कैसे generate करते हैं, और GetHTTPS इसे automatically कैसे handle करता है।
अपने browser में मुफ़्त SSL certificate पाएँ
कोई installation नहीं, कोई account नहीं। आपकी private key कभी आपका device नहीं छोड़ती।
अपना certificate पाएँ