ssl證書生成工具是什么?想必都知道無論申請的是免費ssl證書還是ca頒發(fā)的ssl證書,都是要安裝并生成證書方能正常使用。生成ssl證書的步驟也有所不同,有簡單也有復雜的,那接下來,小編就在這里給大家簡述下ssl證書的生成工具,然后再另外說下ssl證書的作用吧。
ssl證書的作用
ssl證書是數(shù)字證書的一種,類似于駕駛證、護照和營業(yè)執(zhí)照的電子副本。
ssl證書的兩大作用:數(shù)據(jù)加密和身份認證。
ssl 證書遵守 ssl協(xié)議,通過在客戶端瀏覽器和web服務器之間建立一條ssl安全通道。
一個有效、可信的 ssl 數(shù)字證書包括一個公共密鑰和一個私用密鑰。公共密鑰用于加密信息,私用密鑰用于解譯加密的信息。因此,瀏覽器指向一個安全域的時,ssl 將同步確認服務器和客戶端,并創(chuàng)建一種加密方式和一個唯一的會話密鑰。它們可以啟動一個保證消息的隱私性和完整性的安全會話。
簡述ssl證書生成工具
1.創(chuàng)建根證書密鑰文件:
openssl genrsa -des3 -out root.key
輸出內容為:
[lenin@archer ~]$ openssl genrsa -des3 -out root.keygenerating rsa private key, 512 bit long modulus……………..++++++++++++..++++++++++++e is 65537 (0×10001)enter pass phrase for root.key: ← 輸入一個新密碼verifying – enter pass phrase for root.key: ← 重新輸入一遍密碼
2.創(chuàng)建根證書的申請文件root.csr:
openssl req -new -key root.key -out root.csr
輸出內容為:
[lenin@archer ~]$ openssl req -new -key root.key -out root.csrenter pass phrase for root.key: ← 輸入前面創(chuàng)建的密碼you are about to be asked to enter information that will be incorporatedinto 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 blankfor some fields there will be a default value,if you enter ‘.’, the field will be left blank.—–country name (2 letter code) [au]:cn ← 國家代號,中國輸入cnstate or province name (full name) [some-state]:beijing ← 省的全名,拼音locality name (eg, city) []:beijing ← 市的全名,拼音organization name (eg, company) [internet widgits pty ltd]:mycompany corp. ← 公司英文名organizational unit name (eg, section) []: ← 可以不輸入common name (eg, your name) []: ← 此時不輸入email address []:admin@mycompany.com ← 電子郵箱,可隨意填
please enter the following ‘extra’ attributesto be sent with your certificate requesta challenge password []: ← 可以不輸入an optional company name []: ← 可以不輸入
3.創(chuàng)建一個自當前日期起為期一年的根證書root.crt:
openssl x509 -req -days 365 -sha1 -extensions v3_ca -signkey root.key -in root.req -out root.crt
輸出內容為:
[lenin@archer ~]$ openssl x509 -req -days 365 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.crtsignature oksubject=/c=cn/st=beijing/l=beijing/o=mycompany corp./emailaddress=admin@mycompany.comgetting private keyenter pass phrase for root.key: ← 輸入前面創(chuàng)建的密碼
4.創(chuàng)建服務器證書密鑰server.key:
openssl genrsa –des3 -out server.key 2048
輸出內容為:
[lenin@archer ~]$ openssl genrsa -out server.key 2048generating rsa private key, 2048 bit long modulus….+++…………………………………………..+++e is 65537 (0×10001)
運行時會提示輸入密碼,此密碼用于加密key文件(參數(shù)des3便是指加密算法,當然也可以選用其他你認為安全的算法.),以后每當需讀取此文件(通過openssl提供的命令或api)都需輸入口令.如果覺得不方便,也可以去除這個口令,但一定要采取其他的保護措施!去除key文件口令的命令:openssl rsa -in server.key -out server.key
5.創(chuàng)建服務器證書的申請文件server.csr:
openssl req -new -key server.key -out server.csr
輸出內容為:
[lenin@archer ~]$ openssl req -new -key server.key -out server.reqyou are about to be asked to enter information that will be incorporatedinto 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 blankfor some fields there will be a default value,if you enter ‘.’, the field will be left blank.—–country name (2 letter code) [au]:cn ← 國家名稱,中國輸入cnstate or province name (full name) [some-state]:beijing ← 省名,拼音locality name (eg, city) []:beijing ← 市名,拼音organization name (eg, company) [internet widgits pty ltd]:mycompany corp. ← 公司英文名organizational unit name (eg, section) []: ← 可以不輸入common name (eg, your name) []:www.mycompany.com ← 服務器主機名,若填寫不正確,瀏覽器會報告證書無效,但并不影響使用email address []:admin@mycompany.com ← 電子郵箱,可隨便填
please enter the following ‘extra’ attributesto be sent with your certificate requesta challenge password []: ← 可以不輸入an optional company name []: ← 可以不輸入
6.創(chuàng)建自當前日期起有效期為期兩年的服務器證書server.crt:
openssl x509 -req -days 730 -sha1 -extensions v3_req -ca root.crt -cakey root.key -caserial root.srl -cacreateserial -in server.csr -out server.crt
輸出內容為:
[lenin@archer ~]$ openssl x509 -req -days 730 -sha1 -extensions v3_req -ca root.crt -cakey root.key -ca