使用 openssl 產生 SSL 憑證需要的 key 與 csr

先產生key,紅色部份的domainname,按需求改成自己的域名

  • openssl genrsa -des3 -out DomainName.key 2048 


再用 key產生 csr

  • openssl req -new -key DomainName.key -out DomainName.csr

再拿 csr 去賣 ssl 憑證的網站做申請

下面則是產生過程的示例,有輸入資料的部份,請按自己的需求做調整
[root@localhost tmp]# openssl genrsa -des3 -out DomainName.key 2048
Generating RSA private key, 2048 bit long modulus
...........................................................+++
...............................................................+++
e is 65537 (0x10001)
Enter pass phrase for DomainName.key:
aborted!
140396700161864:error:0906906F:PEM routines:PEM_ASN1_write_bio:read key:pem_lib.c:382:
[root@localhost tmp]# openssl genrsa -out DomainName.key 2048
Generating RSA private key, 2048 bit long modulus
...........+++
......................................................+++
e is 65537 (0x10001)
[root@localhost tmp]# openssl req -new -key DomainName.key -out DomainName.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]:XX
State or Province Name (full name) []:OO
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@localhost tmp]# ls DomainName.*
DomainName.csr  DomainName.key

留言

熱門文章