2017-02-03 16 views
0

sslConfig:如何配置jetty以請求指定資源的客戶端證書?

<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory"> 
    <Set name="KeyStorePath">../conf/jetty/etc/keystore</Set> 
    <Set name="KeyStorePassword">secretpass</Set> 
    <Set name="KeyManagerPassword">test</Set> 
    <Set name="TrustStorePath">../conf/jetty/etc/truststore</Set> 
    <Set name="TrustStorePassword">secretpass</Set> 
    <Set name="EndpointIdentificationAlgorithm"></Set> 
    <Set name="NeedClientAuth">true</Set> 
    <Set name="WantClientAuth">true</Set> 
</New> 

設置NeedClientAuth到真正需要的客戶,爲所有資源提供證書。但在我的情況下,我只想要爲特定資源申請證書。

比如我需要請求證書/資源1/* 而僅使用了HTTPS /資源2/*

我怎樣才能做到這一點?

回答

1

不可能,因爲SSL/TLS協商步驟在請求實際發生之前發生。

沒有網絡服務器可以基於請求的資源應用不同的SSL/TLS規則,因爲http請求中存在的信息在SSL/TLS協商時尚未發送。

如果這很重要,請在不同的端口上設置2個不同的ServerConnector。

  1. ServerConnector與客戶端驗證 - 在/resource1/*內容從這裏供應
  2. ServerConnector無客戶端驗證 - 不需要客戶端身份驗證要求所有其他網絡資源(甚至不具備/resource1/*內容)
相關問題