2018/05/12

[Apache] xamppで https 利用するための自己署名証明書の作成方法

XAMPP for WindowsでSSLを有効にする
https://qiita.com/sutara79/items/21a068494bc3a08a4803


1. C:\xampp\apache\conf\extra\httpd-ssl.conf に VirtualHost設定

<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/my-server.crt"
    SSLCertificateKeyFile "conf/ssl.key/my-server.key"
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs"
    ServerName test.localhost
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/my-server.crt"
    SSLCertificateKeyFile "conf/ssl.key/my-server.key"
</VirtualHost>


2. C:\xampp\apache\conf\openssl.cnf 編集

[ req ]セクション
x509_extensions = v3_ca # The extensions to add to the self signed cert
→ x509_extensions = v3_req # The extensions to add to the self signed cert

末尾追記
[ SAN ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = localhost
DNS.2 = test.localhost
# DNS.3 = <他に認証したいドメインがあれば>

→ *.localhost の設定はNG(事由不明)


3. openssl(Git Bash)で証明書作成

cd /c/xampp/apache/conf
openssl req \
    -newkey     rsa:4096 \
    -keyout     my-server.key \
    -x509 \
    -nodes \
    -out        my-server.crt \
    -subj       "//CN=localhost" \
    -reqexts    SAN \
    -extensions SAN \
    -config     openssl.cnf \
    -days       3650


4. 証明書設置
C:\xampp\apache\conf\ssl.crt\my-server.crt
C:\xampp\apache\conf\ssl.key\my-server.key


5. 証明書認証
C:\xampp\apache\conf\ssl.crt\my-server.crt ダブルクリック
→ [証明書のインストール]
→ [保存場所] 現在のユーザー → [次へ]
→ 証明書をすべて次のストアに配置する、[証明書ストア] 信頼されたルート証明機関 → [次へ]
→ [完了] → [はい]


6. Firefoxで自己署名証明書認証の例外設定

0 件のコメント:

コメントを投稿