如何配置jboss服务器以读取客户端证书

时间:2012-09-25 10:57:26

标签: jboss client-certificates

我有一个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");    

每次都给空。

1 个答案:

答案 0 :(得分:0)

您确定客户是否出示证书?

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

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