SSL:GoDaddy SSL證書制作和安裝


簡介

SSL證書是數字證書的一種類似於駕駛證、護照和營業執照的電子副本。因為配置在服務器上,也稱為SSL服務器證書。SSL 證書就是遵守SSL協議,由受信任的數字證書頒發機構CA,在驗證服務器身份后頒發,具有服務器身份驗證和數據傳輸加密功能。

阿里雲SSL證書的配置非常簡單,申請完成,打包下載放到你的web服務器上即可;與阿里雲的SSL證書不同,GoDaddy作為一個專門的域名和SSL證書服務的提供商,其為保證SSL證書的安全性,整個證書的操作過程都需要自己來做,本篇文章就主要介紹在GoDaddy上SSL證書的制作和安裝,同時介紹一下SSL的工作原理,希望對需要的小伙伴有所幫助。

SSL證書的工作原理

證書主要作用是在SSL握手中,我們來看一下SSL的握手過程,如下圖的步驟

  1. 客戶端提交https請求
  2. 服務器響應客戶,並把證書公鑰發給客戶端
  3. 客戶端驗證證書公鑰的有效性
  4. 有效后,會生成一個會話密鑰
  5. 用證書公鑰加密這個會話密鑰后,發送給服務器
  6. 服務器收到公鑰加密的會話密鑰后,用私鑰解密,回去會話密鑰
  7. 客戶端與服務器雙方利用這個會話密鑰加密要傳輸的數據進行通信

img-w500

GoDaddy 證書制作過程

制作CSR證書簽署請求文件

生成證書簽署請求CSR(Certificate Signing Request)文件,本文以glinux.top域名為例,自己使用中請做相應替換,需要填寫的信息中,請注意Common Name,應為泛域名地址,如: *.glinux.top ,在linux命令行,使用openssl工具執行如下命令

openssl req -new -newkey rsa:2048 -nodes -keyout glinux.top.key -out glinux.top.csr

Generating a 2048 bit RSA private key
.......................+++
...................+++
writing new private key to 'glinux.top.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) [XX]:CN
State or Province Name (full name) []:ZhejiangSheng
Locality Name (eg, city) [Default City]:Hangzhou
Organization Name (eg, company) [Default Company Ltd]:glinux
Organizational Unit Name (eg, section) []:DevOps
Common Name (eg, your name or your server's hostname) []:*.glinux.top
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

生成兩個文件,glinux.top.csr為證書簽署請求,glinux.top.key為客戶端解密數據使用的私鑰

img-w500

(可選)將證書簽署請求內容輸入到該網站https://www.ssldun.com/tools/csr-decoder.php#results進行解碼,驗證信息是否正確,如下圖。

img-w500

CA(Certification Authorities)對請求進行簽署

打開GoDaddy中所購買的SSL證書,點擊生成密鑰和管理,填寫相關證書簽署請求內容,即生成的glinux.top.csr文件內容,驗證域名持有者信息,一般有兩種方式,通過郵件或者在DNS添加解析記錄,等待證書的簽發。

img-w500

證書的安裝

待證書簽發完成,找到證書下載頁,選擇對應的web服務類型,如果不存在,請選擇其他,此處以nginx web服務類型為主

img-w500

下載完成,將解壓出的文件合並成一個文件,並命名為crt格式,即為證書文件

cat fd72a4fa7c1de0e3.crt gd_bundle-g2-g1.crt > glinux.top.crt

img-w500

更新nginx配置文件以使用 SSL 證書

server {
    listen       80 default_server;
    server_name  example.htrader.cn;
    return 301 https://$host$request_uri;
}

server {
    listen       443 ssl http2 default_server;
    server_name  example.glinux.top;
    root         /usr/share/nginx/html;

    ssl_certificate "/etc/nginx/conf.d/glinux.top.crt";
    ssl_certificate_key "/etc/nginx/conf.d/glinux.top.key";
    index index.php index.html index.htm
}

參考文檔


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM