当我尝试从Eclipse运行以下代码时,我总是得到返回值为null:
X509Certificate cert[] = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate");
System.out.println("cert: " + cert[0]); //always returns null
有人可以帮我解决这个问题吗?我读到某处说我必须将客户端身份验证值设置为true,但我该怎么做?我使用pom.xml和web.xml(附在下面)
web.xml:
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPS<web-resource-name>
<url-pattern>/*<url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>CLIENT-CERT</auth-method>
</login-config>
pom.xml:
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<httpsPort>8443</httpsPort>
<keystoreFile>${basedir}/certs/keystore.jks</keystoreFile>
<keystorePass>changeit</keystorePass>
</configuration>
非常感谢任何帮助!!
谢谢!
答案 0 :(得分:1)