$ openssl req -new -x509 -days 3650 -key ca.key -out ca.crt ----- Country Name (2 letter code) [AU]:CN State or Province Name (full name) [Some-State]:BJ Locality Name (eg, city) []:BJ Organization Name (eg, company) [Internet Widgits Pty Ltd]:SELF Organizational Unit Name (eg, section) []:SELF Common Name (e.g. server FQDN or YOUR name) []:CA Email Address []:
3、先创建好CA目录,并准备好CA的序列号、索引文件
1 2 3 4
$ mkdir -p demoCA/newcerts $ cd demoCA $ touch index.txt index.txt.attr $ echo 00 > serial
4、用openssl生成随机数种子,当前用户的根目录下执行
1 2 3 4 5
$ openssl rand -writerand .rnd $ pwd /home/top $ ls -rlt .rnd -rw------- 1 top top 1024 12月 4 11:40 .rnd
生成服务端证书
1、生成2048 bit的服务端私钥
1
$ openssl genrsa -out server.key 2048
2、用服务端私钥生成证书签名请求CSR
1 2 3 4 5 6 7 8 9
$ openssl req -new -key server.key -out server.csr ----- Country Name (2 letter code) [AU]:CN State or Province Name (full name) [Some-State]:BJ Locality Name (eg, city) []:BJ Organization Name (eg, company) [Internet Widgits Pty Ltd]:SELF Organizational Unit Name (eg, section) []:SELF Common Name (e.g. server FQDN or YOUR name) []:SERVER Email Address []:
Using configuration from /etc/ssl/openssl.cnf Check that the request matches the signature Signature ok The commonName field needed to be supplied and was missing
Using configuration from /etc/ssl/openssl.cnf Check that the request matches the signature Signature ok The countryName field is different between CA certificate (VN) and the request (CN)
$ openssl req -new -key client.key -out client.csr ----- Country Name (2 letter code) [AU]:CN State or Province Name (full name) [Some-State]:BJ Locality Name (eg, city) []:BJ Organization Name (eg, company) [Internet Widgits Pty Ltd]:SELF Organizational Unit Name (eg, section) []:SELF Common Name (e.g. server FQDN or YOUR name) []:CLIENT Email Address []: