• Rachid
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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