Openssl生成证书

Key是私用秘钥,通常是RSA算法
Csr是证书请求文件,用于申请证书
Crt是CA认证后的证书文件,签署人用自己的key给你签署凭证

1.创建服务器证书密钥文件server.key:
openssl genrsa -out server.key 1024
输入密码,确认密码,记住密码,后面会用到
2.创建服务器证书的申请文件server.csr
openssl req -new -key server.key -out server.csr
需要依次输入国家,地区,组织,email
最重要的是有一个common name,可以写你的名字或者域名,如果为了https申请,这个必须和域名吻合,否则会引发浏览器警报。
输出内容为:
Enter pass phrase for root.key: ← 输入前面创建的密码
Country Name (2 letter code) [AU]:CN ← 国家代号,中国输入CN
State or Province Name (full name) [Some-State]:BeiJing ← 省的全名,拼音
Locality Name (eg, city) []:BeiJing ← 市的全名,拼音
Organization Name (eg, company) [Internet Widgits Pty Ltd]: ← 公司英文名
Organizational Unit Name (eg, section) []: ← 可以不输入
Common Name (eg, YOUR name) []: ← 此时不输入
Email Address []: ← 电子邮箱
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: ← 可以不输入
An optional company name []: ← 可以不输入
4.备份服务器密钥文件
cp server.key server.key.org
5.去除文件口令
openssl rsa -in server.key.org -out server.key
6.生成证书文件server.crt
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt