建立私有证书颁发机构 生成Ca的私钥
[iyunv@localhost ~]# cd /etc/pki/CA/
[iyunv@localhost CA]# (umask 077; openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus
.....................................+++
.........................+++
e is 65537 (0x10001)
[iyunv@localhost CA]#
使用私钥生产自签名证书
[iyunv@localhost CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365
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) [GB]:CN #设置国家名称
State or Province Name (full name) [Berkshire]:HB #设置省份名称
Locality Name (eg, city) [Newbury]:SJG #设置市名称
Organization Name (eg, company) [My Company Ltd]:BENET #设置组织名称
Organizational Unit Name (eg, section) []:LB #设置部门名称
Common Name (eg, your name or your server's hostname) []:www.benet.com #设置主机名需要与颁发的主机名一直,不然会报证书不信任
Email Address []:ca@benet.com #设置电子邮件地址
编辑配置文件***的存放位置
[iyunv@localhost ~]# vim /etc/pki/tls/openssl.cnf
dir = /etc/pki/CA
web服务器配置 准备一个目录存储证书
[iyunv@localhost CA]# cd /etc/httpd/
[iyunv@localhost httpd]# mkdir ssl
[iyunv@localhost httpd]# cd ssl/
生成web的私钥证书
[iyunv@localhost ssl]# (umask 077;openssl genrsa 1024 > httpd.key)
Generating RSA private key, 1024 bit long modulus
............++++++
..........................++++++
e is 65537 (0x10001)
生成证书签署请求
[iyunv@localhost ssl]# openssl req -new -key httpd.key -out 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) [GB]:CN
State or Province Name (full name) [Berkshire]:HB
Locality Name (eg, city) [Newbury]:SJZ
Organization Name (eg, company) [My Company Ltd]:BENET
Organizational Unit Name (eg, section) []:LB
Common Name (eg, your name or your server's hostname) []:www.benet.com #和网站的域名必须保持完全一致
Email Address []:aa@benet.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
CA服务器签署web服务器的证书
[iyunv@localhost ~]# openssl ca -in /etc/httpd/ssl/httpd.csr -out /etc/httpd/ssl/httpd.crt -days 365
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: Nov 26 10:42:56 2014 GMT
Not After : Nov 26 10:42:56 2015 GMT
Subject:
countryName = CN
stateOrProvinceName = HB
organizationName = BENET
organizationalUnitName = LB
commonName = www.benet.com
emailAddress = aa@benet.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
35:F3:EE:62:1F:64:D5:06:DB:5C:60:77:0B:19:33:C2:6A:8B:2D:B4
X509v3 Authority Key Identifier:
keyid:57:72:4C:91:1C:9B:F2:B0:E8:4A:E1:34:AB:03:E6:E6:31:2A:1D:C3
Certificate is to be certified until Nov 26 10:42:56 2015 GMT (365 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
查看颁发情况
[iyunv@localhost CA]# cat index.txt
V 151126104256Z 01 unknown /C=CN/ST=HB/O=BENET/OU=LB/CN=www.benet.com/emailAddress=aa@benet.com 查看下一个请求给的序列号
[iyunv@localhost CA]# cat serial
02