I have this error:
System.CalloutException: IO Exception: Failed to create certificate java.security.cert.CertificateException: Could not decode the client certificate. Please ensure that it is a base64 representation of a PKCS12 file: DerInputStream.getLength(): lengthTag=42, too big.
It was triggered during a SOAP callout from Salesforce to external endpoint.
The IP and domain:port of the external server were added to Remote Site Settings.
clientCert_x and clientCertPasswd_x have been populated with the correct values using the class wsdl2apex.
Certificate is encoded using Base64 and the format is PKCS12 that was converted to JKS and importer to Certificate and Key Management.
Please advise.
Thank you.
답변 16개
Hi to all the future researcher, the fix for this particular problem is to use the base64 string value of the pkcs12 format certificate, no need to convert it into a JKS file.
Instead of this:
sapCallout.clientCert_x = 'certUniqueName';
use this:
sapCallout.clientCert_x = 'base64 string value found from .pem, opened it using notepad and paste it here as single line';
To get the pem file from pkcs12, use this code in command prompt:
openssl base64 -in c:/mycert.p12 -out c:/mycert.pem