Nothing to write. Read these blog posts directly...
Note: Server. xml two-way authentication must be configured with truststorefile.
The browser client p12 certificate must be added to the jks file of the server.
Http://www.blogjava.net/stevenjohn/archive/2012/08/22/385989.html
Http://www.360doc.com/content/10/0401/23/633992_21237818.shtml
Http://www.blogjava.net/stevenjohn/archive/2012/09/27/388647.html
Run the following code to obtain the client certificate. Note: it is valid only for two-way authentication.
<% X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate");if(null!=certs){for(X509Certificate c: certs){PublicKey publicKey = c.getPublicKey();out.println(publicKey.getFormat());out.println("<br/>");//out.println(c.getExtendedKeyUsage());X500Principal flag = c.getSubjectX500Principal();String[] ss = flag.getName().split(",");////CN=WCY_309184,OU=03for(String s:ss){// String[] ss1 = s.split(",", 1);out.println("<br/>");out.println(s);}}}else{out.println("X509Certificate is null.");}%>