当我将 SPDY 与 Jetty 一起使用时,我遇到了客户端证书问题。
当我使用 NPN 并启动 Jetty SPDY 服务器时,它可以工作:
SSLconnector = new HTTPSPDYServerConnector(server, sslContextFactory);
作为baseRequest.getHttpChannel()
它使用org.eclipse.jetty.spdy.server.http.HttpChannelOverSPDY
,我可以读取 SSL 属性SSL_SESSION_ID
和客户端证书,其代码如下:
// ... HttpServletRequest request
java.security.cert.X509Certificate client_certs[] = (java.security.cert.X509Certificate[])request.getAttribute("javax.servlet.request.X509Certificate");
但是 NPN 在 Java8 中不是一个选项(请参阅我的问题How to run Jetty with SPDY using ALPN?)。在 Java8 中,我必须使用 ALPN 协议,例如:
sslContextFactory.setWantClientAuth(w3srv_config.want_client_auth);
// ...
HttpConfiguration httpConfig = new HttpConfiguration();
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, "alpn");
ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory("spdy/3", "http/1.1");
alpn.setDefaultProtocol("http/1.1");
HTTPSPDYServerConnectionFactory spdy = new HTTPSPDYServerConnectionFactory(SPDY.V3, httpConfig);
HttpConnectionFactory http = new HttpConnectionFactory(httpConfig);
SSLconnector = new ServerConnector(server, new ConnectionFactory[]{ssl, alpn, spdy, http});
//...
当null
我想获得任何与 SSL 相关javax.servlet.request.*
的 . 它baseRequest.getHttpChannel()
是org.eclipse.jetty.server.HttpConnection$HttpChannelOverHttp
。
我必须更改哪些内容才能使用客户端证书?