This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can I get a X509Certificate from tomcat

 
qs Wang
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have successfully config the ssl for tomcat , then , I make a "jsp" file contain the follow:
java.security.cert.X509Certificate certChain[] = (java.security.cert.X509Certificate[])request.getAttribute("javax.net.ssl.peer_certificates");
if (certChain != null)
{
//Now in SSL and can use the certificate information to query
//the user and authenticate
out.println("<h1>HTTPS Information:<h1>");
out.println("<pre>");
for (int i = 0;i < certChain.length;i++)
{
out.println(i);
X500Name issuer = certChain[i].getIssuerName().getName();
//doSomethingWith(issurer);
}
}
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
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i have the same problem.
Have you found a solution??
thank's
 
Marco Kempelen
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use de next code in an JSP File, Im waiting this work fine for you.
//----------->
<%@ page import = "java.net.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.security.cert.*" %>
<%

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>");
}
else
{
out.println (certs[0].getSubjectDN().toString());
out.println ();
}
%>
//----------->
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic