28.9. TLS クライアント証明書認証の設定
クライアント証明書認証を使用すると、管理者は、証明書で認証したユーザーのみが Web サーバーのリソースにアクセスできるようにすることが可能です。/var/www/html/Example/
ディレクトリーにクライアント証明書認証を設定できます。
Apache HTTP Server が TLS 1.3 プロトコルを使用する場合、特定のクライアントには追加の設定が必要です。たとえば、Firefox で、about:config
メニューの security.tls.enable_post_handshake_auth
パラメーターを true
に設定します。
前提条件
- サーバーで TLS 暗号化が有効になっています。
手順
/etc/httpd/conf/httpd.conf
ファイルを編集し、以下の設定をクライアント認証を設定する<VirtualHost>
ディレクティブに追加します。<Directory "/var/www/html/Example/"> SSLVerifyClient require </Directory>
<Directory "/var/www/html/Example/"> SSLVerifyClient require </Directory>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow SSLVerifyClient require
の設定では、/var/www/html/Example/
ディレクトリーのコンテンツにクライアントがアクセスする前に、サーバーがクライアント証明書を正常に検証する必要があることを定義します。httpd
サービスを再起動します。systemctl restart httpd
# systemctl restart httpd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
検証
curl
ユーティリティーを使用して、クライアント認証なしでhttps://example.com/Example/
URL にアクセスします。curl https://example.com/Example/
$ curl https://example.com/Example/ curl: (56) OpenSSL SSL_read: error:1409445C:SSL routines:ssl3_read_bytes:tlsv13 alert certificate required, errno 0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow このエラーは、Web サーバーにクライアント証明書認証が必要であることを示しています。
クライアント認証を使用して同じ URL にアクセスするには、クライアントの秘密鍵と証明書、さらに CA 証明書を
curl
に渡します。curl --cacert ca.crt --key client.key --cert client.crt https://example.com/Example/
$ curl --cacert ca.crt --key client.key --cert client.crt https://example.com/Example/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 要求に成功すると、
curl
は/var/www/html/Example/
ディレクトリーに保存されているindex.html
ファイルを表示します。