2

我有一个 PKCS12 密钥库文件。我已经在我的浏览器中导入了它。在我的代码中,我必须检索证书信息和数据。

在 JBOSS EAP 5.1 中是否需要进行任何配置?

    HttpServletRequest req=(HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    X509Certificate[] certs = (X509Certificate[]) req.getAttribute("javax.servlet.request.X509Certificate");    
    if (certs != null) {
    for (int i = 0; i < certs.length; i++) {
    out.println("Client Certificate [" + i + "] = " + certs[i].toString());
    }
    }
    else {
    if ("https".equals(request.getScheme())) {
    out.println("This was an HTTPS request, but no client certificate is available");
    }   

在运行它时。线

X509Certificate[] certs = (X509Certificate[]) req.getAttribute("javax.servlet.request.X509Certificate");    

每次都给null。

4

1 回答 1

0

您确定客户正在出示证书吗?

这可能不是您想要做的,但我在 AS 7 中使用standalone.xml 中配置的安全域做了类似的事情

这个线程几乎解释了这一切: https ://community.jboss.org/thread/172052?start=0&tstart=0

于 2012-11-09T14:15:43.137 回答