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
Vinicius Damasceno 1Vinicius Damasceno 1 

Error Salesforce Callout SOAP certificate "unable to find valid certification path to requested target"

Hi all, 

Im in a trouble while connecting Salesforce to SAP(external system).

I got the wsdl and made the Apex Class.
I have generated the Self Signed Certificate, i put the certificate in Identity Provider.
I Downloaded the certificate and send the certificate as "pem" file to others persons, that said they have installed this "pem" file in the endpoint server.

But I got this error "Line: 84, Column: 1
System.CalloutException: IO Exception: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
when i try to execute the request to webService.

This is my apex Class:

//Generated by wsdl2apex

public class filtrarProdutoIntegracao {
    public class Result_element {
        public String matnr;
        public String netpr;
        public String netwr;
        public String mwsbp;
        public String aufsg;
        private String[] matnr_type_info = new String[]{'matnr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] netpr_type_info = new String[]{'netpr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] netwr_type_info = new String[]{'netwr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] mwsbp_type_info = new String[]{'mwsbp','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] aufsg_type_info = new String[]{'aufsg','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://******.com.br/SALESFORCE/ConsultaPrecoMaterial','false','false'};
        private String[] field_order_type_info = new String[]{'matnr','netpr','netwr','mwsbp','aufsg'};
    }
    public class DT_ConsPrecoMaterial_OB {
        public String vtweg;
        public String werks;
        public String kunnag;
        public String[] matnr;
        public String mgame;
        public String vkpne;
        public String skfbp;
        private String[] vtweg_type_info = new String[]{'vtweg','http://*****..com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] werks_type_info = new String[]{'werks','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] kunnag_type_info = new String[]{'kunnag','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] matnr_type_info = new String[]{'matnr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','-1','false'};
        private String[] mgame_type_info = new String[]{'mgame','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] vkpne_type_info = new String[]{'vkpne','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] skfbp_type_info = new String[]{'skfbp','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://******.com.br/SALESFORCE/ConsultaPrecoMaterial','false','false'};
        private String[] field_order_type_info = new String[]{'vtweg','werks','kunnag','matnr','mgame','vkpne','skfbp'};
    }
    public class DT_ConsPrecoMaterial_IB {
        public filtrarProdutoIntegracao.Result_element[] Result;
        private String[] Result_type_info = new String[]{'Result','http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial','false','false'};
        private String[] field_order_type_info = new String[]{'Result'};
    }
    public class HTTPS_Port {
        public String endpoint_x = 'https://*******.com.br:44300/XISOAPAdapter/MessageServlet?senderParty=SALESFORCE&senderService=SALESFORCE&receiverParty=SALESFORCE&receiverService=SALESFORCE&interface=SI_ConsPrecoMaterial_OB&interfaceNamespace=http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial';
        public Map<String,String> inputHttpHeaders_x = new Map<String,String>();   
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x = 'SelfSignedCert_300522';
       // public String clientCert_x;
        //public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://*****/SALESFORCE/ConsultaPrecoMaterial', 'filtrarProdutoIntegracao'};
        public filtrarProdutoIntegracao.Result_element[] SI_ConsPrecoMaterial_OB(String vtweg,String werks,String kunnag,List<String> matnr,String mgame,String vkpne,String skfbp) {
            filtrarProdutoIntegracao.DT_ConsPrecoMaterial_OB request_x = new filtrarProdutoIntegracao.DT_ConsPrecoMaterial_OB();
            request_x.vtweg = vtweg;
            request_x.werks = werks;
            request_x.kunnag = kunnag;
            request_x.matnr = matnr;
            request_x.mgame = mgame;
            request_x.vkpne = vkpne;
            
            request_x.skfbp = skfbp;
            filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB response_x;
            Map<String, filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB> response_map_x = new Map<String, filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB>();
            response_map_x.put('response_x', response_x);
            //inputHttpHeaders_x.put('Authorization','Basic SU5URUdfU0Y=:MW50M2dyQDIwMjI=');
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://sap.com/xi/WebService/soap1.1',
              'http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial',
              'MT_ConsPrecoMaterial_OB',
              'http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial',
              'MT_ConsPrecoMaterial_IB',
              'filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.Result;
        }
    }
}


I'm stuck somedays in this problems, im glad if someone help me! =)
VinayVinay (Salesforce Developers) 
Hi Vinicius,

This seem to be certificate configuration issue,  KIndly reach out to the endpoint URL supporting team to resolve the certificate issue since the issue is from certificate configuration. Once the certificate issue is resolved this should work.

Use  SSL checkers that can help you fix the issue.

https://www.sslshopper.com/ssl-checker.html

https://salesforce.stackexchange.com/questions/205533/salesforce-callout-unable-to-find-valid-certification-path-but-from-postman-i

Please mark as Best Answer if above information was helpful.

Thanks,