Created
January 29, 2014 10:48
-
-
Save edpichler/8685637 to your computer and use it in GitHub Desktop.
Ler certificado digital em Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
publicclass LerCertificado extends HttpServlet { | |
protectedvoid doGet(HttpServletRequest request, | |
HttpServletResponse response) throws ServletException, IOException { | |
PrintWriter out = response.getWriter(); | |
out.println(""); | |
out.println("ServletLerCertificado"); | |
out.println(""); | |
out.println("Certificado digital:"); | |
String cipherSuite = (String) request.getAttribute("javax.servlet.request.cipher_suite"); | |
if (cipherSuite != null) { | |
java.security.cert.X509Certificate certChain[] = (java.security.cert.X509Certificate[]) | |
request.getAttribute("javax.servlet.request.X509Certificate"); | |
System.out.println("Array size: " + certChain.length); | |
if (certChain != null) { | |
for (int i = 0; i < certChain.length; i++) { | |
String certInfo = "Client Certificate [" + i + "] = " + certChain[i].toString(); | |
out.println(certInfo); | |
} | |
} | |
} else { | |
out.println("Cliente sem Certificado Digital"); | |
} | |
out.println("");//new line | |
out.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment