SSL 是 用於 用戶 和  Web 服務器 之間網路封包聯繫的加密的技術

CA 證書是 對 網路封包 進行加密憑證,因此可以 減少 駭客 竊f取資訊的機會。
自己 發行的 CA證書 可以使用,但無法使用在 信用卡 或是 PayPal  等金融環境中。

Step 1 – Install mod_ssl Package

為了設置 CA 證書,請確保您的系統上安裝了 mod_ssl。 如果尚未安裝,請使用以下命令進行安裝。 安裝以創建CA證書。

dnf install mod_ssl openssl

 

Step 2 – 建立屬於自已發行的 認證中心

安裝 mod_ssl 和 openSSL 後,使用以下命令為自己的 名 創建自簽名證書。(或是查看)

mkdir -p /etc/pki/tls/certs  # 建立 目錄
cd /etc/pki/tls/certs        # 轉進 路徑 (當前目錄)

建立 新的  CA 證書

 openssl req -x509 -nodes -newkey rsa:2048 -keyout first.com.key -out first.com.crt
 openssl req -x509 -nodes -newkey rsa:2048 -days 1825 -keyout first.com.key -out first.com.crt 

上述命令將在當前目錄中創建一個 ssl 密鑰文件 first.com.key 和一個證書文件 first.com.crt

Step 3 – 在 Apache 配置 SSL 虛擬主機 port 443

vi /etc/httpd/conf.d/BBB_SSL.conf      # 建立 SSL 虛擬主機 環境設定 檔
<VirtualHost *:443>
   ServerAdmin admin@first.com
   DocumentRoot /var/www/first.com
   ServerName www.first.com
   ServerAlias www.first.com
   <Directory /var/www/first.com>
      #Allowoverride all Uncomment if required
   </Directory>
   SSLEngine on # 將此設置為“開”
   SSLCertificateFile /etc/pki/tls/certs/first.com.crt # 設置 SSL 證書的位置
   SSLCertificateKeyFile /etc/pki/tls/certs/first.com.key # 設置 SSL 私鑰證書的位置
   ErrorLog  logs/first.com_ssl-error.log
   CustomLog logs/first.com_ssl-access.log combined
</VirtualHost>

 

Step 4 – 重啟 Apache

systemctl restart httpd

 

Step 5 – 使用 HTTPS 測試網站

最後,使用 https 在您喜歡的 Web 瀏覽器中打開您的站點。

它需要打開端口 443 才能使用 https 訪問站點.

由於我們使用的是自己發行的CA證書,您將在瀏覽器中收到一條警告消息。 您可以簡單地忽略此消息.

THE END

參考

How to Create and Install Self Signed Certificate in Apache

個人頭像照片

By 伍 芳左

MIS, ERP Pro...

發佈留言