
我正在嘗試設定啟用客戶端認證的 Apache 伺服器。這樣客戶就可以使用有效的客戶端憑證來存取內容。
比方說,我的伺服器運行為
https://myserver/myservice/
另外,我需要為我的客戶提供一個接口,透過提供一些身份驗證資訊來獲取他們的客戶端證書
https://myserver/myservice/register
上傳資訊驗證通過後,返回客戶端證書。
如果我理解正確,這條路徑應該被排除在客戶端認證機制之外,只是因為它用於產生憑證。那麼問題是,如何指定 httpd 配置來實現這一目標?
我目前的配置如下:
ProxyPass /myservice/register http://localhost:4444/register
<Virtualhost *:443>
ServerName myserver
DocumentRoot /path/to/my/server/root
ProxyPass /myservice/ ajp://localhost:8009/myservice/
SSLEngine on
SSLProtocol all -SSLv2
SSLCertificateFile /path/to/server.cert
SSLCertificateKeyFile /path/to/server.key
...
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile /path/to/ca.buddle.pem
</Virtualhost>
透過此配置,我可以從中獲取客戶端證書
http://myserver/myservice/register
然後使用它來存取服務。然而,我沒有設法將其設定為https,以便我可以關閉80連接埠。
答案1
現在我得到了解決方案,只需使用 or 排除目標 URL 路徑即可。
<Virtualhost *:443>
ServerName myserver
DocumentRoot /path/to/my/server/root
ProxyPass /myservice/register http://localhost:4444/register
ProxyPass /myservice/ ajp://localhost:8009/myservice/
SSLEngine on
SSLProtocol all -SSLv2
SSLCertificateFile /path/to/server.cert
SSLCertificateKeyFile /path/to/server.key
...
SSLVerifyClient require
SSLVerifyDepth 10
SSLCACertificateFile /path/to/ca.buddle.pem
<LocationMatch ^/myservice/register$>
SSLVerifyClient none
</LocationMatch>
</Virtualhost>