在向Web服务对象提供SSL证书时获取异常

时间:2013-02-28 11:00:56

标签: c# winforms web-services soap ssl

我正在使用使用Web服务的应用程序的窗口。该Web服务要求客户​​端传递SSL证书及其对象。但我得到了例外 “加密异常未处理未指定错误”。

这是我的代码:

Property24ListingService _service = new Property24ListingService();

            // code to tell your application that you have no problems with self-signed SSL certificate
            ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) 
            {
                return(true); 
            };

                webRef1.CredentialsHeader header = new webRef1.CredentialsHeader();
                header.EMail = email;
                header.Password = pwd;

                _service.CredentialsHeaderValue = header;
              //  _service.ClientCertificates.Add(X509Certificate.CreateFromCertFile(cerPath));
                X509Certificate cer = new X509Certificate(X509Certificate.CreateFromCertFile(cerPath));
                _service.ClientCertificates.Add(cer);

                MessageBox.Show(_service.EchoAuthenticated("hi"));

                var agent = _service.FetchAgent(94);
                MessageBox.Show(agent.ToString());

我正在线上我正在创建“X509Certificate”对象。

任何帮助都会很棒!

0 个答案:

没有答案