Retrieving certificate info...

O

ohaya

Hi,

I have an SSL-enabled Apache + Tomcat with mod_jk2. Apache is configured
to require client certificates, and I've confirmed that this client
authentication seems to be working (see below).

I have a JSP where I want to retrieve some info from the client
certificate.

Here's the code that I'm trying to use for retrieving the certificate
info:

out.println("<BR><BR><B>Client Certificate Info:</B><BR>");
X509Certificate[] certs =
(X509Certificate[])request.getAttribute("javax.servlet.request.X509Certificate");
if (certs != null)
{
X509Certificate cert = certs[0];
String dn = cert.getSubjectDN().getName();
out.println(dn);
}
else
{
out.println("Certs returned NULL");
}

BUT, I am finding 'certs' is always null :(!!

I added some additional code to display some other info from the
request:

Client Info:
request.getRemoteHost(): jimnew.foo.com
request.getRemoteAttr(): 192.168.0.120
request.getProtocol(): HTTP/1.1
request.getScheme(): https
request.isSecure(): yes
request.getAuthType(): null
request.getRemoteUser(): null
request.getMethod(): GET
request.getRequestURI(): /showcert.jsp
request.getServletPath(): /showcert.jsp
request.getContentType(): null
request.getContentLength(): 0
request.getCharacterEncoding(): null

When I connect with a client, I am getting a popup asking to select my
client certificate.

Can anyone tell me why the 'certs' is always returning null, and how can
I retrieve the DN/subjectName?

Thanks,
Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top