How does one create a java.security.cert.X509Certificate
instance from a PEM-formatted String? The PEM-formatted String is a HTTP request \"SSL_CLIENT_CERT\" h
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));
}