Websphere App Server 双向 SSL - 从客户端证书认证中获取 CN

Websphere App Server mutual SSL - obtain CN from client certificate authentication

我有:

我需要 SSL 相互身份验证,所以我转到保护质量 (QoP) 设置,并设置客户端身份验证 = 必需。 到目前为止一切正常。

问题是我的 EJB 应用程序需要客户端证书的通用名称来获取用户 ID,它将在业务逻辑中使用。在这里我失败了。 代码片段(网络服务端):

        MessageContext context = wsContext.getMessageContext();
        HttpServletRequest req = (HttpServletRequest)context.get(MessageContext.SERVLET_REQUEST) ;
        System.out.println("!! isSecure " + req.isSecure());

        X509Certificate[] certificates = (X509Certificate[]) req.getAttribute("java.servlet.request.X509Certificate");
        if (null != certificates && certificates.length > 0) {
              ...
        } else {
            System.out.println("!! Empty certificates");
        }

isSecure 返回 true,但我收到 "Empty certificates" 消息。

我的猜测可能是以下原因。当我输出 9449 端口上使用的 SSL 配置时,第一行是 "com.ibm.ssl.clientAuthenticationSupported = false",而通过管理控制台将其设置为必需。

com.ibm.websphere.ssl.JSSEHelper jsseHelper  = com.ibm.websphere.ssl.JSSEHelper.getInstance();
java.util.Properties props = jsseHelper.getProperties("WebServiceConfigure");
            System.out.println("!!! WebServiceConfigure = " + props.toString());

您可能想尝试 "direct connect" 证书属性。这是为了解决颁发与最终客户端不同的证书的中间(SSL 终止)代理(如带有插件的 Web 服务器)而创建的。这个属性是

com.ibm.websphere.ssl.direct_connection_peer_certificates

您可以确定您是通过 com.ibm.websphere.webcontainer.is_direct_connection 从直接连接对等点还是从代理对等点获取证书。

另请参阅:WAS 9 doc page