【问题标题】:Spring Security X.509 PreauthSpring Security X.509 Preauth
【发布时间】:2013-05-03 23:02:18
【问题描述】:

我正在使用带有 X.509 证书的 Spring Security 2.x 的 Preauthentication。

我通过HttpServletRequest.getAttribute("CERTIFICATE") 得到certificateText

有时,上述调用会返回""(空)。我相信它会在 HTTP 会话过期时发生。

什么可以解释为什么HttpServletRequest.getAttribute("CERT") 返回空?

编辑 例如,在 Kerberos 中,票证在每个 HTTP 请求中都可用。证书不总是在 X.509 HTTP 请求中吗?

【问题讨论】:

    标签: gwt spring-security pre-authentication


    【解决方案1】:
    1. 请使用此代码访问证书: X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate");
    2. 在客户端证书身份验证成功后,始终会填充证书以请求。

    确保您支持长证书链:

    1. 将 max_packet_size 属性添加到 worker.properties 文件中 worker.ajp13w.max_packet_size=65536

    2. 在 Tomcat 配置 \conf\server.xml 中将 packetSize 属性添加到 Ajp 连接器的配置中 <Connector port="8089" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" packetSize="65536"/>

    Apache 日志: http://httpd.apache.org/docs/2.2/logs.html#accesslog http://httpd.apache.org/docs/2.2/logs.html#errorlog http://httpd.apache.org/docs/2.2/mod/core.html#loglevel

    【讨论】:

    • 那么如果客户端证书认证失败,那么HTTP会话不会包含javax.servlet.request.X509Certificate属性?我添加了日志语句以打印出request.getAttributeNames(),然后遍历它们。有时不会有javax.servlet.request.X509Certificate 证书。找出失败原因的关键是 Apache 日志?
    • 如何连接 Apache 和 servlet 容器? AJP?
    • Apache 和 Tomcat 通过mod_jk 交谈。但我确实设置了这个属性:conf.d/workers.properties:worker.eurekastreams.type=ajp13
    • 根据您的编辑,我已经在 Apache 和 Tomcat 配置中设置了这些值。
    • 您是否有某个特定的证书没有出现或者同一个证书有时会消失?
    猜你喜欢
    • 1970-01-01
    • 2015-07-17
    • 2012-05-24
    • 1970-01-01
    • 2012-05-05
    • 2015-12-12
    • 1970-01-01
    • 2016-11-07
    • 2017-10-01
    相关资源
    最近更新 更多