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
David VPDavid VP 

apex Webservices call out and salesforce client certificate

Hello,


We need to make a call from apex code to an external webservice. This webservice is secured by a BASIC Http username/password and requires a client certificate. The IIS server right now trusts the salesforce client certificate.
I was wondering how (or if ?) we could use the salesforce client certificate to present to the webservice. The (pseudo) code we have right now is :

Code:
String encodedusernameandpassword;
  String HelloWorld;
  
        myStub.TestServiceSoap soap = new myStub.TestServiceSoap();
               
        soap.inputHttpHeaders_x = new Map<String, String>();
                
        String myData = 'username:password';
        Blob hash = Crypto.generateDigest('SHA1',Blob.valueOf(myData));       
        encodedusernameandpassword = EncodingUtil.base64Encode(hash);
        
        //Setting a basic authentication header
        soap.inputHttpHeaders_x.put('Authorization', 'Basic '+ encodedusernameandpassword);
        soap.clientCert_x = ????
        soap.clientCertPasswd_x = 'passwd';

        HelloWorld = soap.HelloWorld();

 
Apparently you can set the client certificate using the .inputHttpHeaders_x(...) method. Can we use the Salesforce client certificate here somehow ? (if yes : how) or do we need to create our own private certificate and have the webservice trust that one ?

thanks for your thoughts,


David
cheenathcheenath
Please see this post:

http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=5693



David VPDavid VP

Exactly the answer I was looking for.


Thanks a lot !!!


-david-
RachidRachid

Hi,.

 

I have the same pb, but the link is not availble.

can sharing your solution plz