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

C# 向Web服务对象提供SSL证书时获取异常,c#,winforms,web-services,soap,ssl,C#,Winforms,Web Services,Soap,Ssl,我正在从使用web服务的应用程序中使用window。该web服务要求客户端将SSL证书与其对象一起传递。但我有个例外 “未处理加密异常未指定错误” 这是我的密码: Property24ListingService _service = new Property24ListingService(); // code to tell your application that you have no problems with self-signed SSL certifi

我正在从使用web服务的应用程序中使用window。该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()); Property24ListingService_service=新的Property24ListingService(); //用于告诉应用程序自签名SSL证书没有问题的代码 ServicePointManager.ServerCertificateValidationCallback=委托(对象obj、X509证书证书、X509链、SslPolicyErrors) { 返回(真); }; webRef1.CredentialsHeader=新的webRef1.CredentialsHeader(); header.EMail=电子邮件; header.Password=pwd; _service.CredentialsHeaderValue=标题; //_service.ClientCertificates.Add(X509Certificate.CreateFromCertFile(cerPath)); X509Certificate cer=新的X509Certificate(X509Certificate.CreateFromCertFile(cerPath)); _service.ClientCertificates.Add(cer); MessageBox.Show(_service.echocauthenticated(“hi”); var-agent=_-service.FetchAgent(94); Show(agent.ToString()); 我在创建“X509Certificate”对象的那一行得到了异常

任何帮助都会很好