● Linux:
● Windows (Chocolatey):
● Windows (Scoop):
預設下載位置在 /usr/local/ssl/bin
● 查詢openssl 版本
建議使用 ver.1.0.2beta之後版本,1.0.1~1.0.2 受到 Heartbleed Bug 影響
genrsa
: 表示產生 RSA 金鑰的操作。
-des3
: 表示使用 3DES 加密演算法對產生的私密金鑰進行加密,並要求使用者輸入密碼來保護私密金鑰。
-out server.key
: 指定產生的私鑰的輸出檔名為 server.key
2048
: 指定產生的RSA 金鑰的長度為 2048 位元。 #國際密碼學規範需使用2048bits以上金鑰
OpenSSL 會產生一個有密碼保護的 RSA 私鑰檔案server.key
,並使用 3DES 演算法對私鑰進行加密。產生金鑰後會要求輸入密碼(PEM pass phase)
以後使用私鑰時都會需要輸入。
憑證請求檔(CSR)通常會發送給證書頒發機構(CA) 以獲取相應的數位證書,以便在伺服器上使用 HTTPS 等安全協定。
openssl
: OpenSSL 工具的命令列工具。
req
: 表示產生憑證簽發要求的操作。
-new
: 表示建立一個新的憑證要求。
-key server.key
: 指定私鑰檔案 server.key 用於產生憑證請求。
-out certrequest.txt
: 指定產生的憑證要求的輸出檔案名稱 certrequest.txt。
產出過程中需要進行身分驗證:
會列出
依照證書頒發機構填寫 個人/公司/法人 資料 如中華電信: Reference: https://publicca.hinet.net/documents.htm
在取得 CA 認證的 Public CA 簽發憑證後
中華電信公開金鑰基礎建設: 中華電信自簽憑證
中華電信公開金鑰基礎建設: 中華電信自身通用憑證
複製到檔案
下一步(N)
選擇
密碼編譯訊息語法標準- PKCS #7 憑證 (.P7B)Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
勾選如果可能的話,包含憑證路徑中的所有憑證Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
存檔
已成功匯出並串聯 ROOTeCA(根憑證) & Public CA(中繼CA憑證)
將完成匯出的 .P7B 複製到 Apache Server
使用FTP需要以Binary格式傳輸Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
原憑證(.P7B檔)為 DER encode,需要轉換成 PEM encode (Base64)
openssl
: OpenSSL 工具的命令列工具。
pkcs7
: 表示 PKCS#7 相關操作。
-in eCA_PublicCA.p7b
: 指定輸入的 PKCS#7 檔案名為 eCA_PublicCA.p7A。
-inform DER
: 指定輸入檔的格式為DER 格式。PKCS#7 檔案可以以 DER 或 PEM 格式儲存。
-print_certs
: 指示輸出列印 PKCS#7 檔案中所包含的憑證。
-out eCA_PublicCA.pem
: 指定輸出檔案的檔案名為eCA_PublicCA.pem,並將憑證以 PEM 格式儲存。
● Linux:
● Windows:
C:\xampp\apache\conf\ssl.crt 依照自己 Apache 不同環境選擇不同資料夾Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
編輯 httpd-ssl.conf 設定檔
httpd-ssl 會根據不同環境存在不同的資料夾中 (大多都在 apache\conf 資料夾底下)
將 SSLCertificateChainFile 取消註解,加入上步驟產出的CA.CRT路徑
若收到的 CA 簽發的 cer 檔為 PEM encode,則可忽略此步驟1。
驗證方式: 使用文字編輯器開啟 cer 檔
1.顯示亂碼: DER encode
2.顯示 BEGIN CERTIFICATE 開頭: PEM encode
原憑證(.cer)為 DER encode,需要轉換成 PEM encode (Base64)
openssl
: OpenSSL 工具的命令列工具。
x509
: 表示 X.509 相關操作。
-in server.cer
: 指定輸入的 X.509 憑證檔案名稱 server.cer。
-inform DER
: 指定輸入檔的格式為DER 編碼。X.509 憑證可以以 DER 或 PEM 格式儲存。
-out server.pem
: 指定輸出檔案的檔案名為 server.pem,並將憑證以 PEM 格式儲存。
● Linux (.cer):
● Windows (.cer):
● Linux (.pem):
● Windows (.pem):
C:\xampp\apache\conf\ssl.crt 依照自己 Apache 不同環境選擇不同資料夾Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
編輯 httpd-ssl.conf 設定檔
httpd-ssl 會根據不同環境存在不同的資料夾中 (大多都在 apache\conf 資料夾底下)
將 SSLCertificateFile 編輯成上步驟產出的 SERVER.CRT 路徑
將步驟 1. 產生RSA 私鑰 產生的 server.key 複製到 /apache/conf/ssl.key 下
編輯 httpd-ssl.conf 設定檔
httpd-ssl 會根據不同環境存在不同的資料夾中 (大多都在 apache\conf 資料夾底下)
將 SSLCertificateKeyFile 編輯成匯入的 SERVER.KEY 路徑
若伺服器無法重啟遇到以下相關ERROR,無法重啟:
AH02577: Init: SSLPassPhraseDialog builtin is not supported on Win32 (key file C:/xampp/apache/conf/ssl.key/{your Private key})
AH02311: Fatal error initialising mod_ssl, exiting. See C:/xampp/apache/logs/error.log for more information
AH02564: Failed to configure encrypted (?) private key www.example.com:443:0, check C:/xampp/apache/conf/ssl.key/{your Private key}
SSL Library Error: error:04800068:PEM routines::bad password read – You entered an incorrect pass phrase!?
SSL Library Error: error:1E08010C:DECODER routines::unsupported (No supported data to decode. Input type: DER, Input structure: type-specific)
SSL Library Error: error:068000A8:asn1 encoding routines::wrong tag
SSL Library Error: error:0688010A:asn1 encoding routines::nested asn1 error
SSL Library Error: error:0688010A:asn1 encoding routines::nested asn1 error (Field=version, Type=RSAPrivateKey)
SSL Library Error: error:0688010A:asn1 encoding routines::nested asn1 error (Field=version, Type=PKCS8_PRIV_KEY_INFO)
SSL Library Error: error:1E08010C:DECODER routines::unsupported (No supported data to decode. Input type: DER, Input structure: type-specific)
SSL Library Error: error:0688010A:asn1 encoding routines::nested asn1 error (Type=RSAPrivateKey)
SSL Library Error: error:0688010A:asn1 encoding routines::nested asn1 error (Type=PKCS8_PRIV_KEY_INFO)
可能是 SSL 金鑰格式錯誤。先確保 SSL 金鑰檔案是正確的 PEM 格式,並且密碼 pass phrase 正確。 可使用以下 command,轉換 key 格式 (CER > PEM)
重啟後瀏覽伺服器,確認完成SSL安裝
Note
若憑證過期需更換,請參考: Apache SSL 憑證更換
Apache
SSL
TLS