[iyunv@LNMP nginx-1.8.1]# nginx -V
nginx version: nginx/1.8.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_ssl_module
[iyunv@LNMP ssl]# openssl genrsa -des3 -out test.key 1024
Generating RSA private key, 1024 bit long modulus
..............................++++++
...........................++++++
e is 65537 (0x10001)
Enter pass phrase for test.key: #输入密码,需要复杂性要求
Verifying - Enter pass phrase for test.key: #重复密码
2)拷贝刚才的密码文件,生成一个不需要密码的密钥文件:
1
2
3
[iyunv@LNMP ssl]# openssl rsa -in test.key -out test_nopass.key
Enter pass phrase for test.key: #输入以上创建时输入的密码
writing RSA key
[iyunv@LNMP ssl]# openssl req -new -key test.key -out test.csr
Enter pass phrase for test.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) [XX]:cn #国家
State or Province Name (full name) []:shanghai #省份
Locality Name (eg, city) [Default City]:shanghai #城市
Organization Name (eg, company) [Default Company Ltd]:shanghai information company Ltd #具体名称
Organizational Unit Name (eg, section) []:test #单位名称
Common Name (eg, your name or your server''s hostname) []:*.test.cn #服务器域名
Email Address []:admin@test.cn #邮箱
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: #密码为空,直接回车
An optional company name []: #密码为空,直接回车
4)自己签发证书
1
2
3
4
5
[iyunv@LNMP ssl]# openssl x509 -req -days 365 -in test.csr -signkey test.key -out test.crt
Signature ok
subject=/C=cn/ST=shanghai/L=shanghai/O=shanghai information company Ltd/OU=test/CN=*.test.cn/emailAddress=admin@test.cn
Getting Private key
Enter pass phrase for test.key: #输入test.key设置的密码