openssl genrsa -des3 -out ca.key 1024
Generating RSA private key, 1024 bit long modulus
...............++++++
.............................................++++++
e is 65537 (0x10001)
Enter pass phrase for ca.key:
Verifying - Enter pass phrase for ca.key:
输入pass, 我们可以得到ca.key,这是一个RSA PRIVATE KEY。
接下来就可以用这个ca.key来创建证书。
openssl req -new -x509 -days 20 -key ca.key -out ca.crt
Enter pass phrase for ca.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) []:SH
State or Province Name (full name) []:SH
Locality Name (eg, city) []:SH
Organization Name (eg, company) []:HW
Organizational Unit Name (eg, section) []:HW
Common Name (eg, fully qualified host name) []:caserver
Email Address []:flydean@163.com
openssl req -new -key ca.key -out server.csr
Enter pass phrase for ca.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) []:CN
State or Province Name (full name) []:SH
Locality Name (eg, city) []:SH
Organization Name (eg, company) []:citi
Organizational Unit Name (eg, section) []:org
Common Name (eg, fully qualified host name) []:client
Email Address []:flydean@163.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
csr请求因为也是需要生成一个CA证书,所以也需要输入类似的信息。
最后我们生成了一个server.csr文件。
接下来使用这个csr文件去请求证书:
openssl x509 -req -days 20 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt
Signature ok
subject=/C=CN/ST=SH/L=SH/O=citi/OU=org/CN=client/emailAddress=flydean@163.com
Getting CA Private Key
Enter pass phrase for ca.key: