Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Error message :PKIX path building failed: unable to find valid certification path to requested target

Hello all please see the above exception.I am getting a callout exception .Is any pointer on why the exception is ?

Http h = new Http();
    HttpRequest req = new HttpRequest();
    Oauth1 reuest=new Oauth1();
    reuest.sign(req);//This method generates me header 
    HttpResponse res = h.send(req);
    System.debug('RESPONSE BODY'+ res.getBody());
share|improve this question
up vote 7 down vote accepted

Visiting I notice that your site/service isn't certified with an ssl certificate signed by some verified certificate authority (CA). Salesforce will therefore not accept the certificate and you get the exception you're seeing. You can either switch to unencrypted http or buy a proper certificate or try making your web service talk to SF with certificates which are issued by a CA trusted by SF.

This is of course only possible if you control the endpoint you're trying to talk to. Check out:

Here's a pointer as to which CA's are accepted as valid authorities by SF:

share|improve this answer
Can you please explain me whats unencrypted http?And how i go about it ? – Mohith Shrivastava Dec 20 '12 at 11:04
Change from: req.setEndpoint('https:...'); to req.setEndpoint('http:...'); – Martin Peters Dec 20 '12 at 11:05
i added only http but this gave me an exception of 301 .Moved permanently.any idea?Thanks lot for your help – Mohith Shrivastava Dec 20 '12 at 11:10
Since you're dealing with an oauth authenticated endpoint, I don't think skipping https is an especially good production-grade option. 301 probably means you've been redirected from http to https by the server meaning the server you're trying to talk to requires https. – Martin Peters Dec 20 '12 at 11:12
thanks for your insight and heartfelt thanks .I accepted your answer too – Mohith Shrivastava Dec 20 '12 at 12:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.