Hi,
Can any one help me out to solve this issue.
Here is my code for selecting .
CBSVService.CBSVServices objser = new CBSVService.CBSVServices();
string serverpath = "https://etews.ssa.gov/CBSVWS/services/CBSVServices?wsdl";
NetworkCredential mycred = new NetworkCredential("username", "password");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serverpath);
objser.Credentials = mycred;
objser.ClientCertificates.Add(GetCertFromPfx());
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
CBSVService.ActionResponse acp = objser.ping();
code for getting certificate from a local file path
private X509Certificate2 GetCertFromPfx()
{
string _certificateDirectory = "certificate.pfx";
System.Security.SecureString p = null;
string certPwd = "certpassword";
char[] chars = new char[certPwd.Length];
for (int index = 0; index < certPwd.Length; index++)
chars[index] = certPwd[index];
unsafe
{
//Instantiate a new secure string.
fixed (char* pChars = chars)
{
p = new System.Security.SecureString(pChars, chars.Length);
}
}
X509Certificate2 cert = new X509Certificate2();
cert.Import(_certificateDirectory, p, X509KeyStorageFlags.MachineKeySet);
return cert;
}