openssl生免费证书--亲自实践有效

openssl生免费证书

1.建立文件夹而且建立证书私钥

makdir -p /data/cert
cd /data/cert
openssl genrsa -des3 -out server.key 2048

效果以下,会让你输入密码并确认密码记住后边有用。shell

Generating RSA private key, 2048 bit long modulus
......................................................................................................................+++
..........+++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:

2.根据证书私钥进行生成证书

openssl req -new -key server.key -out server.csr

效果以下,填写上边的密码,而后填写我的信息,能够随便天写ui

[root@zjdk cert]# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.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.
-----
# 国家CN
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]:xxxx
# 单位名称
Organizational Unit Name (eg, section) []:xxxx
# 域名
Common Name (eg, your name or your server's hostname) []:crazyk.com.cn
# 邮箱
Email Address []:code_dking@163.com
Please enter the following 'extra' attributes
to be sent with your certificate request
# 不须要,剩下的两个直接回车就能够
A challenge password []:
An optional company name []:

3.备份私钥

cp server.key server.key.org

4.转换证书

#转换为证书
openssl rsa -in server.key.org -out server.key

效果以下,这个仍是须要输入最开始填写的密码code

[root@zjdk cert]# openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key

5.给证书签名

#给证书签名
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

效果以下,表示成功,完结撒花orm

[root@zjdk cert]# openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=cn/ST=beijing/L=beijing/O=xx/OU=cre.com/CN=cer.com/emailAddress=code_dking.com
Getting Private key
相关文章
相关标签/搜索