SUSE Linux SSL/TLS 設定指南(含 TLS 強化設定)
本指南適用於 openSUSE 與 SUSE Linux Enterprise (SLE),介紹如何安裝與設定 Apache SSL 模組、產生 CSR、配置 SSL 憑證,以及進行 TLS 安全強化。
目錄
安裝 OpenSSL 與 Apache SSL 模組
-
安裝 OpenSSL(用於憑證管理)
sudo zypper refresh sudo zypper install -y openssl
-
安裝 Apache2 及 SSL 模組
sudo zypper install -y apache2 apache2-mod_ssl
-
啟動並設定 Apache 開機自動啟動
sudo systemctl enable --now apache2
產生私鑰與 CSR
以下示範在 /etc/apache2/ssl
下進行操作,請先建立目錄:
sudo mkdir -p /etc/apache2/ssl
cd /etc/apache2/ssl
-
產生 4096 位元 RSA 私鑰
sudo openssl genpkey -algorithm RSA -out server.key -pkeyopt rsa_keygen_bits:4096 sudo chmod 600 server.key
-
產生 CSR(Certificate Signing Request)
sudo openssl req -new -key server.key -out server.csr
系統將提示輸入:
- Country Name (2 letter code) [XX]: TW
- State or Province Name: Taipei
- Locality Name: Taipei
- Organization Name: YourOrg
- Organizational Unit Name: IT Dept
- Common Name: your.domain.com
- Email Address: admin@your.domain.com
-
(測試用)產生自簽名憑證
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
正式環境請使用合法 CA 簽發的憑證。
設定 Apache 使用 SSL
-
啟用 SSL 模組
sudo a2enmod ssl
-
建立或編輯 SSL 虛擬主機設定
在/etc/apache2/vhosts.d/
下建立ssl.conf
:<VirtualHost *:443> ServerName your.domain.com DocumentRoot /srv/www/htdocs SSLEngine on SSLCertificateFile /etc/apache2/ssl/server.crt SSLCertificateKeyFile /etc/apache2/ssl/server.key <Directory "/srv/www/htdocs"> AllowOverride All Require all granted </Directory> </VirtualHost>
-
開放防火牆通訊埠
sudo firewall-cmd --add-service=https --permanent sudo firewall-cmd --reload
-
重新啟動 Apache
sudo systemctl restart apache2
強化 TLS 設定
為提升安全性,建議僅允許 TLS 1.2 及 1.3,並停用弱加密演算法。
-
編輯全域 SSL 設定
修改/etc/apache2/mod_ssl.conf
或/etc/apache2/ssl-global.conf
(如存在):# 僅允許 TLS 1.2 與 1.3 SSLProtocol TLSv1.2 TLSv1.3 # 強制使用安全密碼套件 SSLCipherSuite HIGH:!aNULL:!MD5:!3DES:!RC4 SSLHonorCipherOrder on # 停用壓縮與 Session Ticket SSLCompression off SSLSessionTickets off
-
啟用 HSTS(HTTP Strict Transport Security)
在虛擬主機中加入:Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
-
重新啟動 Apache
sudo systemctl restart apache2
測試與驗證 SSL/TLS 設定
-
使用
openssl s_client
測試openssl s_client -connect your.domain.com:443 -tls1_2 openssl s_client -connect your.domain.com:443 -tls1_3
-
使用
curl
測試 HTTPScurl -I https://your.domain.com
-
線上測試
前往 SSL Labs 輸入網域,檢驗憑證與安全評分。
結語
本指南介紹了在 SUSE Linux 上安裝 OpenSSL 與 Apache SSL 模組、產生 CSR、設定 SSL 虛擬主機,以及進階 TLS 強化與測試方法。建議配合自動化部署與定期憑證更新,確保通信安全與合規。