function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hetal ShethHetal Sheth 

IO Exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I have used self-signed certificate in third party server.
I have done below code to call third party server. I can access that tried party servers WSDL  by providing username and password in browser. It is using SOAP as webservice.
I can also access and post the data by soap ui.I can success fully post request on third party server with below information.
Code
-----------
public class soapWebserviceForHomeKeepers {
    public static long soapWebserviceForAgencyData(){        
     serviceArmHudGov.ArmServiceImplPort innerobj=new serviceArmHudGov.ArmServiceImplPort();
        innerobj.inputHttpHeaders_x = new Map<String, String>();
        String username = 'sdfsdf';
        String password = 'sdfsdf';
        Blob headerValue = Blob.valueOf(username + ':' + password);
        String authorizationHeader = 'Basic ' +EncodingUtil.base64Encode(headerValue);        
        innerobj.inputHttpHeaders_x.put('Authorization',authorizationHeader);
        innerobj.inputHttpHeaders_x.put('Cookie', 'name=value');
        serviceArmHudGov.submissionHeader5_0_element submissionHeader5_0_elementObj= new serviceArmHudGov.submissionHeader5_0_element();
        submissionHeader5_0_elementObj.agcHcsId='123123';
        submissionHeader5_0_elementObj.agcName='123123';
        submissionHeader5_0_elementObj.fiscalYearId='21';
        submissionHeader5_0_elementObj.cmsVendorId='79';
        submissionHeader5_0_elementObj.cmsPassword='113223';
        innerobj.endpoint_x='https://armpilot.hud.gov/ARM/ARM/';
        long submissionId= innerobj.postAgencyData(submissionHeader5_0_elementObj,'TEXT/XML','http://island.zymr.com/rohit/testAgencyProfileData.xml');
        return submissionId;   
    }
    
}
---------
end

But when I am using same information in apex code it giving me error below error.
IO Exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

So can any let me know where i am doing mistake ?
 
ShashankShashank (Salesforce Developers) 
Please see if this helps: http://salesforce.stackexchange.com/questions/5603/why-do-i-get-pkix-path-building-failed-exception-with-my-callout