OpenSSL x509 命令详解:证书查看与解析

openssl x509 是日常运维中最常用的证书查看工具。本文聚焦于查看和解析证书信息,不涉及证书生成。 基本语法 1 openssl x509 [options] -in <certificate file> 常用查看命令 查看证书完整信息 1 openssl x509 -in cert.pem -text -noout 输出包含:版本、序列号、签名算法、颁发者、有效期、主体、公钥、扩展信息。 只查看关键字段 1 2 3 4 5 6 7 8 9 10 11 # 查看主体(Subject) openssl x509 -in cert.pem -subject -noout # 查看颁发者(Issuer) openssl x509 -in cert.pem -issuer -noout # 查看有效期 openssl x509 -in cert.pem -dates -noout # 查看序列号 openssl x509 -in cert.pem -serial -noout 查看公钥信息 1 openssl x509 -in cert....

March 27, 2026 · 2 min · 黑豆子

CSR(证书签名请求)详解与实践

什么是 CSR? CSR(Certificate Signing Request,证书签名请求) 是申请 SSL/TLS 证书时向证书颁发机构(CA)提交的文件。它包含了申请者的公钥和身份信息,由申请者的私钥签名。 CSR 的用途 申请 SSL/TLS 证书 - 向 CA 提交 CSR 申请服务器证书 身份验证 - CSR 中的信息用于验证申请者身份 密钥关联 - 将公钥与域名/组织信息绑定 CSR 包含哪些信息? 一个标准的 CSR 包含以下信息: 字段 说明 示例 C (Country) 国家代码 CN ST (State) 州/省 Beijing L (Locality) 城市 Beijing O (Organization) 组织名称 Example Corp OU (Organization Unit) 部门 IT Department CN (Common Name) 通用名称/域名 example.com emailAddress 电子邮件 admin@example.com 此外,CSR 还包含: 公钥 - 与私钥配对的公钥 签名 - 使用私钥生成的数字签名 可选扩展 - 如 Subject Alternative Name (SAN) 使用 OpenSSL 生成 CSR 基本命令格式 1 2 3 4 5 # 生成私钥的同时生成 CSR(交互式) openssl req -new -newkey rsa:2048 -nodes -keyout domain....

March 24, 2026 · 4 min · 黑豆子