I wish to extract certificate information from my servlet that is
running within tomcat. The problem that I get is that my x509
certificate array is always null. The code snippet that I am attempting
to use is:
X509Certificate[] certs = (X509Certificate[])
request.getAttribute("javax.servlet.request.X509Certificate");
if (certs == null) {
// do non-ssl items
} else {
// Attempt to extract principal name from Subject:
String clientDN = certs[0].getSubjectDN().getName();
System.out.println("Client DN = " + clientDN);
}
My understanding is that when I use the getAttribute as I have above, I
am supposed to get an array of X509Certificate objects. Instead, certs
is always null. The above code is in the doPost method of a servlet
that has received data sent to it using SSL.
I am running tomcat 5.0.27 with java 1.4.2_06.
Any ideas?
Regards,
Andrew Friebel