Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Java Callout reading PublicKeys from HTTP Header

Dear Madame or Sir

I have a java callout reading the client certificate chain out of an HTTP header:

messageContext.getRequestMessage().getHeadersAsObject("javax.servlet.request.X509Certificate");

The trace shows that the returned value is of type Object[] and that the first element of this Array is of type java.security.cert.X509Certificate []

CDR.JWSTCredentialMapper.getUser.objCerts[] [Ljava.lang.Object;@47b95597
CDR.JWSTCredentialMapper.getUser.objCerts[0] [Ljava.security.cert.X509Certificate;@1f774476

Unfortunately when I try to cast the first element of the array to java.security.cert.X509Certificate [] I get

Exception: java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.security.cert.X509Certificate;

How can I extract the X509Certificate object?

Gladly awaiting your answer

Kind Regards

Carlo De Rossi

0 2 425
2 REPLIES 2
Top Solution Authors