Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

how to get a request SOAP xml from webservice using digital signed certificate.

$
0
0

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;
        }




Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>