Convert A PEM-formatted String To A Java.security.cert.X509Certificate
Answer : Decode the Base64 to binary, with some InputStream reading it, then try CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate cert = cf.generateCertificate(is); I have a similar problem, I'm pasting also here the java code that worked for me in case anyone neaded it : import java.util.Base64; public static X509Certificate parseCertificate(String _headerName, HttpServletRequest _request) throws CertificateException { String certStr = _request.getHeader("x-clientcert"); //before decoding we need to get rod off the prefix and suffix byte [] decoded = Base64.getDecoder().decode(certStr.replaceAll(X509Factory.BEGIN_CERT, "").replaceAll(X509Factory.END_CERT, "")); return (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(decoded)); } The steps in conversion of PEM formatted String is opposite of how (x509 -> String) took place. Sample...