[iyunv@CA CA]# (umask 077;openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus
....................................................................................................................................................+++
.....................................................................................+++
e is 65537 (0x10001)
1.3 使用openssl给CA服务器生成自签名证书
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[iyunv@CA CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem
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) []:Beijing
Locality Name (eg, city) [Default City]:Beijing
Organization Name (eg, company) [Default Company Ltd]:magedu
Organizational Unit Name (eg, section) []:ops
Common Name (eg, your name or your server's hostname) []:ca.test.com
Email Address []:ca@test.com
1.4 创建CA相关目录和文件,指定序列号起始数字
1
2
3
[iyunv@CA CA]# touch index.txt #新建索引文件
[iyunv@CA CA]# touch serial #建立序列号文件
[iyunv@CA CA]# echo 01 > serial #写入起始序列号
web服务器创建申请证书
2. 创建申请证书
2.1 在web服务器配置目录创建ssl目录
1
[iyunv@study ~]# mkdir /etc/httpd/ssl
2.2 生成httpd 服务私钥
1
2
3
4
5
[iyunv@study ~]# (umask 077;openssl genrsa -out /etc/httpd/ssl/httpd.key 1024)
Generating RSA private key, 1024 bit long modulus
..................++++++
..............................++++++
e is 65537 (0x10001)
[iyunv@study ~]# openssl req -new -key /etc/httpd/ssl/httpd.key -out /etc/httpd/ssl/httpd.csr
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) []:Beijing
Locality Name (eg, city) [Default City]:Beijing
Organization Name (eg, company) [Default Company Ltd]:magedu
Organizational Unit Name (eg, section) []:ops
Common Name (eg, your name or your server's hostname) []:www1.linux.com
Email Address []:ops@admin.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[iyunv@CA tmp]# openssl ca -in httpd.csr -out httpd.crt -days 3650
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Dec 15 18:13:23 2015 GMT
Not After : Dec 12 18:13:23 2025 GMT
Subject:
countryName = CN
stateOrProvinceName = Beijing
organizationName = magedu
organizationalUnitName = ops
commonName = www1.linux.com
emailAddress = ops@admin.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
D0:C4:3B:E1:C4:59:25:D4:0E:DF:AF:83:9C:48:D6:A8:D9:CC:27:27
X509v3 Authority Key Identifier:
keyid:67:CC:F6:A8:E6:0B:73:CE:6C:A1:6D:B8:A6:99:1F:CA:7A:A3:D3:AB
Certificate is to be certified until Dec 12 18:13:23 2025 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated