I am trying to send an Http request from Salesforce to a third party system. Following is the code for http request.
HTTP httpInstance = new HTTP();
HTTPRequest request = new HTTPRequest();
request.setEndpoint(endpointURL);
request.setHeader('Content-Type','application/json');
request.setHeader('srcKey', 'xxx-xxx-xxx-xxx');
request.setMethod('POST');
//request.setClientCertificateName(certificate);
//request.setClientCertificateName('StudentScoutCertificateBase64');
try{
HTTPResponse newResponse = httpInstance.send(request);
string responseBody = newResponse.getBody();
system.debug('REST Response '+ responseBody);
}catch(exception e){
system.debug('An unexpected error occured: '+ e.getMessage());
}
On sending the request I get a response back from the server with the following error.
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Certificate is valid on client's server. I did download the certificate with Base64 encoding . I then added the certificate using the following
request.setClientCertificateName(certificate);
I am then getting the following error.
common.apex.runtime.impl.ExecutionException: DER input, Integer tag error
Not sure how to proceed with this error. Any help is appreciated. Thanks!