×

ssl證書使用方法以及SSL證書的作用

分類:建站推廣 編輯:虛機世界 瀏覽量:107
2021-04-15 15:58:08

  無論是申請免費的或CA簽發(fā)的SSL證書,都需要安裝生成后才能正常使用。生成SSL證書的步驟從簡單到復(fù)雜各不相同。那接下來小編就給朋友們先講述下一般ssl證書生成方法以及SSL證書的作用,想要進一步了解ssl證書生成的朋友們,趕緊過來看一下,別錯過了。


  SSL證書生成
  1.創(chuàng)建根證書密鑰文件:
  openssl genrsa -des3 -out root.key
  輸出內(nèi)容為:
  [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
  輸出內(nèi)容為:
  [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)建一個自當(dāng)前日期起為期一年的根證書root.crt:
  openssl x509 -req -days 365 -sha1 -extensions v3_ca -signkey root.key -in root.req -out root.crt
  輸出內(nèi)容為:
  [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)建服務(wù)器證書密鑰server.key:
  openssl genrsa –des3 -out server.key 2048
  輸出內(nèi)容為:
  [lenin@archer ~]$ openssl genrsa -out server.key 2048Generating RSA private key, 2048 bit long modulus….+++…………………………………………..+++e is 65537 (0×10001)
  運行時會提示輸入密碼,此密碼用于加密key文件(參數(shù)des3便是指加密算法,當(dāng)然也可以選用其他你認(rèn)為安全的算法.),以后每當(dāng)需讀取此文件(通過openssl提供的命令或API)都需輸入口令.如果覺得不方便,也可以去除這個口令,但一定要采取其他的保護措施!去除key文件口令的命令:openssl rsa -in server.key -out server.key
  5.創(chuàng)建服務(wù)器證書的申請文件server.csr:
  openssl req -new -key server.key -out server.csr
  輸出內(nèi)容為:
  [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 ← 服務(wù)器主機名,若填寫不正確,瀏覽器會報告證書無效,但并不影響使用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)建自當(dāng)前日期起有效期為期兩年的服務(wù)器證書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
  輸出內(nèi)容為:
  [lenin@archer ~]$ openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAcreateserial -in server.csr -out server.crtSignature oksubject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./CN=www.mycompany.com/emailAddress=admin@mycompany.comGetting CA Private KeyEnter pass phrase for root.key: ← 輸入前面創(chuàng)建的密碼
  7.創(chuàng)建客戶端證書密鑰文件client.key:
  openssl genrsa -des3 -out client.key 2048
  輸出內(nèi)容為:
  [lenin@archer ~]$ openssl genrsa -des3 -out client.key 2048Generating RSA private key, 2048 bit long modulus……………………………………………………………………………..+++……………………………………………………………………………………………………….+++e is 65537 (0×10001)Enter pass phrase for client.key: ← 輸入一個新密碼Verifying – Enter pass phrase for client.key: ← 重新輸入一遍密碼
  8.創(chuàng)建客戶端證書的申請文件client.csr:
  openssl req -new -key client.key -out client.csr
  輸出內(nèi)容為:
  [lenin@archer ~]$ openssl req -new -key client.key -out client.csrEnter pass phrase for client.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) []:Lenin ← 自己的英文名,可以隨便填Email Address []:admin@mycompany.com ← 電子郵箱,可以隨便填
  Please enter the following ‘extra’ attributesto be sent with your certificate requestA challenge password []: ← 可以不填A(yù)n optional company name []: ← 可以不填
  9.創(chuàng)建一個自當(dāng)前日期起有效期為兩年的客戶端證書client.crt:
  openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in client.csr -out client.crt
  輸出內(nèi)容為:
  [lenin@archer ~]$ openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAcreateserial -in client.csr -out client.crtSignature oksubject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./CN=www.mycompany.com/emailAddress=admin@mycompany.comGetting CA Private KeyEnter pass phrase for root.key: ← 輸入上面創(chuàng)建的密碼
  10.將客戶端證書文件client.crt和客戶端證書密鑰文件client.key合并成客戶端證書安裝包client.pfx:
  openssl pkcs12 -export -in client.crt -inkey client.key -out client.pfx
  輸出內(nèi)容為:
  [lenin@archer ~]$ openssl pkcs12 -export -in client.crt -inkey client.key -out client.pfxEnter pass phrase for client.key: ← 輸入上面創(chuàng)建的密碼Enter Export Password: ← 輸入一個新的密碼,用作客戶端證書的保護密碼,在客戶端安裝證書時需要輸入此密碼Verifying – Enter Export Password: ← 確認(rèn)密碼
  11.保存生成的文件備用,其中server.crt和server.key是配置單向SSL時需要使用的證書文件,client.crt是配置雙向SSL時需要使用的證書文件,client.pfx是配置雙向SSL時需要客戶端安裝的證書文件
  .crt文件和.key可以合到一個文件里面,把2個文件合成了一個.pem文件(直接拷貝過去就行了)
 
ssl證書生成
  SSL證書的作用
  SSL證書是數(shù)字證書的一種,類似于駕駛證、護照和營業(yè)執(zhí)照的電子副本。
  SSL證書的兩大作用:數(shù)據(jù)加密和身份認(rèn)證
  SSL 證書遵守 SSL協(xié)議,通過在客戶端瀏覽器和Web服務(wù)器之間建立一條新網(wǎng)SSL安全通道
  一個有效、可信的 SSL 數(shù)字證書包括一個公共密鑰和一個私用密鑰。公共密鑰用于加密信息,私用密鑰用于解譯加密的信息。因此,瀏覽器指向一個安全域時,SSL 將同步確認(rèn)服務(wù)器和客戶端,并創(chuàng)建一種新網(wǎng)加密方式和一個唯一的會話密鑰。它們可以啟動一個保證消息的隱私性和完整性的安全會話。
 
ssl證書生成
  SSL證書包括
  1,CA證書,也叫根證書或者中間級證書。如果是單向https認(rèn)證的話,該證書是可選的。不安裝CA證書的話,瀏覽器默認(rèn)是不安全的。
  2,服務(wù)器證書,必選項。通過key,證書請求文件csr,再通過CA證書簽名,生成服務(wù)器證書。
  以上就是ssl證書生成方法以及SSL證書的作用,對于SSL證書安裝步驟相對簡單。但是OV SSL和EV SSL證書的安裝就相對比較復(fù)雜了,數(shù)據(jù)審計也比較嚴(yán)格。如果不了解這方面,建議還是找專業(yè)人士幫忙安裝。


聲明:免責(zé)聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻自行上傳,本網(wǎng)站不擁有所有權(quán),也不承認(rèn)相關(guān)法律責(zé)任。如果您發(fā)現(xiàn)本社區(qū)中有涉嫌抄襲的內(nèi)容,請發(fā)

送郵件至:operations@xinnet.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,本站將立刻刪除涉嫌侵權(quán)內(nèi)容。本站原創(chuàng)內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時

需注明出處:新網(wǎng)idc知識百科

免費咨詢獲取折扣

Loading