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
rvsrrvsr 

Problem in using certificate in Apex callout

Hii everybody ,

I have a certificate with .cer extension and  my requirement is to  make an apex callout using this certificate. But i was confusing where to place this certificate file  and use this.

Kindly let me know if any any steps to follow ..
Ashish_SFDCAshish_SFDC
Hi , 


Using Certificates with SOAP Services: 

The following example illustrates the last step of the previous procedure and works with the sample WSDL file in Understanding the Generated Code. This example assumes that you previously generated a certificate with a Unique Name of DocSampleCert.
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.clientCertName_x = 'DocSampleCert';
String input = 'This is the input string';
String output = stub.EchoString(input);
There is a legacy process for using a certificate obtained from a third party for your organization. Encode your client certificate key in base64, and assign it to the clientCert_x variable on the stub. This is inherently less secure than using a Salesforce certificate because it does not follow security best practices for protecting private keys. When you use a Salesforce certificate, the private key is not shared outside Salesforce.
Note
Do not use a client certificate generated under Setup, in Develop | API | Generate Client Certificate. You must use a certificate obtained from a third party for your organization if you use the legacy process.
The following example illustrates the legacy process and works with the sample WSDL file in Understanding the Generated Code.
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.clientCert_x =
'MIIGlgIBAzCCBlAGCSqGSIb3DQEHAaCCBkEEggY9MIIGOTCCAe4GCSqGSIb3DQEHAaCCAd8EggHb'+
'MIIB1zCCAdMGCyqGSIb3DQEMCgECoIIBgjCCAX4wKAYKKoZIhvcNAQwBAzAaBBSaUMlXnxjzpfdu'+
'6YFwZgJFMklDWFyvCnQeuZpN2E+Rb4rf9MkJ6FsmPDA9MCEwCQYFKw4DAhoFAAQU4ZKBfaXcN45w'+
'9hYm215CcA4n4d0EFJL8jr68wwKwFsVckbjyBz/zYHO6AgIEAA==';

// Password for the keystore
stub.clientCertPasswd_x = 'passwd';

String input = 'This is the input string';
String output = stub.EchoString(input);


http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_client_certs_soap.htm


Regards,
Ashish