This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Security and the fly likes how can I get a X509Certificate from tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » Security
Bookmark "how can I get a X509Certificate from tomcat " Watch "how can I get a X509Certificate from tomcat " New topic

how can I get a X509Certificate from tomcat

qs Wang

Joined: Nov 04, 2002
Posts: 7
I have successfully config the ssl for tomcat , then , I make a "jsp" file contain the follow: certChain[] = ([])request.getAttribute("");
if (certChain != null)
//Now in SSL and can use the certificate information to query
//the user and authenticate
out.println("<h1>HTTPS Information:<h1>");
for (int i = 0;i < certChain.length;i++)
X500Name issuer = certChain[i].getIssuerName().getName();
but , "certChain" is null. why? it is sure that I send a Certificate from the client(IE), why I can not get the Certificate from tomcat. who can help me ? tks all!
malzac jerome

Joined: Nov 27, 2004
Posts: 1
hi, i have the same problem.
Have you found a solution??
Marco Kempelen

Joined: Oct 14, 2004
Posts: 3
Use de next code in an JSP File, Im waiting this work fine for you.
<%@ page import = "*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "*" %>

if (!request.isSecure())
out.println ("<h3>Warning</h3>");
out.println ("<b>This connection was not done via SSL. Can't authenticate via client certificates.</b>");
X509Certificate[] certs = (X509Certificate[])request.getAttribute("javax.servlet.request.X509Certificate");
if (certs == null || certs.length == 0)
out.println ("<h3>Warning</h3>");
out.println ("<b>This SSL connection didn't retrieve any client certificates.</b>");
out.println (certs[0].getSubjectDN().toString());
out.println ();
I agree. Here's the link:
subject: how can I get a X509Certificate from tomcat