1

I'm getting the following error when trying to send data to a remote site.

06:39:14.11 (12427104)|CALLOUT_REQUEST|[16]|System.HttpRequest[Endpoint=https://endpoint.url/, Method=POST]
06:39:14.11 (90917484)|CALLOUT_REQUEST|[16]|System.HttpRequest retrying request in response to handshake failure: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
06:39:14.11 (107486232)|EXCEPTION_THROWN|[16]|System.CalloutException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
06:39:14.11 (107701237)|USER_DEBUG|[18]|DEBUG|Callout error: System.CalloutException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
06:39:14.11 (107760777)|USER_DEBUG|[19]|DEBUG|System.HttpResponse[Status=null, StatusCode=0]

I have referenced this help article already and it appears our certificates are setup as described: https://help.salesforce.com/articleView?id=000005287&type=1

public class CloudtoDevOps {    
    @future (callout=true)
    public static void sendNotification(String ClientID, String Name, String Status, String Datacenter, Decimal Users, Decimal Storage) {

        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();

        req.setEndpoint('https://endpoint.url/');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json;charset=UTF-8');
        req.setBody('[{"client_id": "' + ClientId + '", "client_full_name": "' + Name + '", "status": "' + Status + '", "hosted_datacenter": "' + Datacenter + ', "number_of_licenses": "' + Users + ', "storage_amount_in_gb": "' + Storage + '" }]');
        req.setCompressed(true);

        try {
            res = http.send(req);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug(res.toString());
        }

    }
}

Which is envoked using the following trigger:

trigger CloudtoDev on Cloud_Environment__c (after insert, after update) {
    for (Cloud_Environment__c c: Trigger.new) {
        CloudtoDevOps.SendNotification(c.Client_ID__c, c.Name, c.Status__c, c.Data_Center__c, c.Users__c, c.Storage_Amount__c);
    }
}

I'm not sure why I encounter this error. Any help would be appreciated.

  • I have no clue about this, but it reminded me of this question: salesforce.stackexchange.com/questions/140258/… Maybe that answer will help you. – Kasper Aug 4 '17 at 22:07
  • Thanks. I saw that and we are using one of the certificates Salesforce supports. I have also confirmed the certificates on our server are installed correctly. – Ronak Aug 5 '17 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.