सभी SSL articles SSL और Certificates

OpenSSL Commands Cheat Sheet for SSL Certificates

OpenSSL SSL/TLS certificates के लिए Swiss Army knife है। इस site पर हर दूसरे article में OpenSSL commands reference हैं — यह page उन सभी को एक ही जगह collect करता है।

Certificate check करें

Certificate details देखें (remote server)

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -text

Expiry date check करें

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate

Subject और SANs check करें

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName

Issuer check करें (कौन सा CA)

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -issuer

Local certificate file check करें

openssl x509 -in cert.pem -noout -text
openssl x509 -in cert.pem -noout -dates          # सिर्फ dates
openssl x509 -in cert.pem -noout -subject         # सिर्फ subject
openssl x509 -in cert.pem -noout -ext subjectAltName  # सिर्फ SANs

Certificate chain verify करें

Chain completeness check करें (remote)

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null
# देखें:
#   Verify return code: 0 (ok)          ← Chain complete है
#   Verify return code: 21 (unable to verify) ← Chain incomplete है

Chain file के against certificate verify करें

openssl verify -CAfile chain.pem cert.pem
# Expected: cert.pem: OK

Check करें कि certificate और key match करते हैं

# ये दोनों hashes same होने चाहिए
openssl x509 -noout -modulus -in cert.pem | openssl md5
openssl rsa -noout -modulus -in privkey.pem | openssl md5
# ECDSA keys के लिए:
openssl ec -in privkey.pem -pubout 2>/dev/null | openssl md5
openssl x509 -in cert.pem -pubkey -noout | openssl md5

Keys generate करें

openssl ecparam -genkey -name prime256v1 -noout -out privkey.pem

RSA 2048

openssl genrsa -out privkey.pem 2048

RSA 4096

openssl genrsa -out privkey.pem 4096

CSR generate करें

ECDSA

openssl req -new -key privkey.pem -out csr.pem -subj "/CN=example.com"

SANs के साथ (multi-domain)

openssl req -new -key privkey.pem -out csr.pem \
  -subj "/CN=example.com" \
  -addext "subjectAltName=DNS:example.com,DNS:www.example.com"

CSR inspect करें

openssl req -in csr.pem -noout -text

CSR क्या है? →

Formats convert करें

PEM → PFX (Windows/IIS के लिए)

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

PFX → PEM

openssl pkcs12 -in cert.pfx -clcerts -nokeys -out cert.pem
openssl pkcs12 -in cert.pfx -nocerts -nodes -out privkey.pem
openssl pkcs12 -in cert.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

Certificate formats explained →

TLS connections debug करें

कौन सा TLS version negotiate हुआ, check करें

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | grep "Protocol"

Specific TLS version test करें

# TLS 1.2 test
echo | openssl s_client -connect example.com:443 -servername example.com -tls1_2 2>/dev/null | grep "Protocol"

# TLS 1.3 test
echo | openssl s_client -connect example.com:443 -servername example.com -tls1_3 2>/dev/null | grep "Protocol"

Full handshake show करें

openssl s_client -connect example.com:443 -servername example.com -msg

Supported cipher suites check करें

# server द्वारा accept किए जाने वाले सभी ciphers list करें
nmap --script ssl-enum-ciphers -p 443 example.com

Self-signed certificate generate करें (सिर्फ development के लिए)

openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 \
  -keyout key.pem -out cert.pem -days 365 -nodes \
  -subj "/CN=localhost" \
  -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"

Trusted localhost HTTPS के लिए, इसकी जगह mkcert use करें।

Separate files से fullchain.pem बनाएँ

cat cert.pem chain.pem > fullchain.pem

Order important है: पहले आपका certificate, फिर intermediate(s)।

FAQ

मैं OpenSSL कैसे install करूँ?

ज़्यादातर Linux distributions में यह included होता है। macOS पर: brew install openssl। Windows पर: Git for Windows (OpenSSL included है) या Chocolatey (choco install openssl) से install करें।

openssl x509 और openssl s_client में क्या difference है?

x509 एक local certificate file read करता है। s_client एक remote server से connect होता है और उसका certificate fetch करता है। Live server check करने के लिए s_client use करें; disk पर file inspect करने के लिए x509 use करें।

मेरे commands “unable to load certificate” क्यों show करते हैं?

File probably DER-encoded (binary) है, PEM (text) नहीं। Command में -inform DER add करें:

openssl x509 -in cert.der -inform DER -noout -text

संबंधित लेख

डिप्लॉयमेंट 2026-05-07
SSL Certificate की Expiry कैसे Check करें
अपने browser, OpenSSL, या online tools use करके check करें कि आपका SSL certificate कब expire होता है। Unexpected expiry और downtime से बचने के लिए monitoring set करें।
SSL और Certificates 2026-05-07
SSL Certificate Formats: PEM, PFX, DER explained
PEM, PFX/PKCS#12, और DER certificate formats को समझें। जानें आपके server को कौन सा format चाहिए और OpenSSL से उनके बीच कैसे convert करें।
SSL और Certificates 2026-05-07
Certificate Chain of Trust की explanation
Browser root CA से intermediate CA से आपके certificate तक की chain के through SSL certificates को कैसे verify करते हैं। जानें chain order क्यों matter करता है और 'certificate not trusted' errors को कैसे fix करें।
SSL और Certificates 2026-05-07
ECC vs RSA Certificates: आपको कौन सा choose करना चाहिए?
ECC (ECDSA P-256) और RSA (2048/4096-bit) certificates compare करें। ECC keys छोटी और fast होती हैं। जानें GetHTTPS ECC को default क्यों रखता है और RSA कब sense बनाता है।
अपने browser में मुफ़्त SSL certificate पाएँ
कोई installation नहीं, कोई account नहीं। आपकी private key कभी आपका device नहीं छोड़ती।
अपना certificate पाएँ