Retrieving certificate info...

Discussion in 'Java' started by ohaya, Aug 17, 2004.

  1. ohaya

    ohaya Guest

    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
    ohaya, Aug 17, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Nagle
    Replies:
    11
    Views:
    624
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Dec 14, 2006
  2. Rymfax
    Replies:
    1
    Views:
    484
    Victor Bazarov
    Apr 13, 2007
  3. Helena Cai
    Replies:
    0
    Views:
    380
    Helena Cai
    Aug 29, 2004
  4. Replies:
    0
    Views:
    399
  5. Peter
    Replies:
    4
    Views:
    126
    Peter
    May 19, 2008
Loading...

Share This Page