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: PKIX path building failed: 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.
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('Cookie', 'name=value');
        serviceArmHudGov.submissionHeader5_0_element submissionHeader5_0_elementObj= new serviceArmHudGov.submissionHeader5_0_element();
        long submissionId= innerobj.postAgencyData(submissionHeader5_0_elementObj,'TEXT/XML','');
        return submissionId;   

But when I am using same information in apex code it giving me error below error.
IO Exception: PKIX path building failed: 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: