$ openssl genrsa -des3 -out root.key Generating RSA private key, 512 bit long modulus ……………..++++++++++++ ..++++++++++++ e is 65537 (0×10001) Enter pass phrase for root.key: ← 输入一个新密码 Verifying – Enter pass phrase for root.key: ← 重新输入一遍密码
$ openssl req -new -key root.key -out root.req Enter pass phrase for root.key: ← 输入前面创建的密码 You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. —– 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]:MyCompany Corp. ← 公司英文名 Organizational Unit Name (eg, section) []: ← 可以不输入 Common Name (eg, YOUR name) []: ← 此时不输入 Email Address []:admin@mycompany.com ← 电子邮箱,可随意填 Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 可以不输入 An optional company name []: ← 可以不输入
$ openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.req -out root.crt Signature ok subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./emailAddress=admin@mycompany.com Getting Private key Enter pass phrase for root.key: ← 输入前面创建的密码
4.创建服务器证书密钥server.key
1
openssl genrsa -out server.key 2048
输出内容为:
1 2 3 4 5
$ openssl genrsa -out server.key 2048 Generating RSA private key, 2048 bit long modulus ….+++ …………………………………………..+++ e is 65537 (0×10001)
5.创建服务器证书的申请文件server.req
1
openssl req -new -key server.key -out server.req
输出内容为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
$ openssl req -new -key server.key -out server.req You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. —– 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]:MyCompany Corp. ← 公司英文名 Organizational Unit Name (eg, section) []: ← 可以不输入 Common Name (eg, YOUR name) []:www.mycompany.com ← 服务器主机名,若填写不正确,浏览器会报告证书无效,但并不影响使用 Email Address []:admin@mycompany.com ← 电子邮箱,可随便填 Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 可以不输入 An optional company name []: ← 可以不输入
$ openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in server.req -out server.crt Signature ok subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./CN=www.mycompany.com/emailAddress=admin@mycompany.com Getting CA Private Key Enter pass phrase for root.key: ← 输入前面创建的密码
7.创建客户端证书密钥文件client.key
1
openssl genrsa -des3 -out client.key 2048
输出内容为:
1 2 3 4 5 6 7
$ openssl genrsa -des3 -out client.key 2048 Generating RSA private key, 2048 bit long modulus ……………………………………………………………………………..+++ ……………………………………………………………………………………………………….+++ e is 65537 (0×10001) Enter pass phrase for client.key: ← 输入一个新密码 Verifying – Enter pass phrase for client.key: ← 重新输入一遍密码
$ openssl genrsa -des3 -out client.key 2048 Generating RSA private key, 2048 bit long modulus ……………………………………………………………………………..+++ ……………………………………………………………………………………………………….+++ e is 65537 (0×10001) Enter pass phrase for client.key: Verifying – Enter pass phrase for client.key: [lenin@archer ~]$ openssl req -new -key client.key -out client.req Enter pass phrase for client.key: ← 输入上一步中创建的密码 You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. —– 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]:MyCompany Corp. ← 公司英文名 Organizational Unit Name (eg, section) []: ← 可以不填 Common Name (eg, YOUR name) []:Lenin ← 自己的英文名,可以随便填 Email Address []:admin@mycompany.com ← 电子邮箱,可以随便填 Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 可以不填 An optional company name []: ← 可以不填