【问题标题】:exchange web services x509 Certivicate交换 Web 服务 x509 证书
【发布时间】:2011-08-21 12:01:23
【问题描述】:

我正在尝试连接到 Exchange Web 服务,以通过我自己的 Web 服务 (ASP/WCF) 代表用户发送电子邮件。我的代码在能够连接到交换服务器的台式电脑上运行时运行良好,但是在通过互联网运行时交换服务器无法访问,因此我尝试通过我的网络服务器进行连接。

我正在寻找在不使用 Exchange Web 服务模拟的情况下以其他用户身份登录的方法(因为我被告知不要使用它,除非绝对没有其他方法)并且用户不提供密码。

我有以下代码:

Dim service As New Microsoft.Exchange.WebServices.Data.ExchangeService(Microsoft.Exchange.WebServices.Data.ExchangeVersion.Exchange2007_SP1)
Dim emailAddress As String = "example@example.com"
System.Net.ServicePointManager.ServerCertificateValidationCallback = AddressOf CertificateValidationCallBack


Dim cert As New System.Security.Cryptography.X509Certificates.X509Certificate2(HttpContext.Current.Request.ClientCertificate.Certificate)
service.Credentials = New Microsoft.Exchange.WebServices.Data.WebCredentials(New System.Security.Cryptography.X509Certificates.X509Certificate())
service.UseDefaultCredentials = False

但这不起作用,因为Unable to cast object of type 'System.Security.Cryptography.X509Certificates.X509Certificate' to type 'System.Net.ICredentials'. 异常。

谁能指导我如何使用 X509 证书对 Exchange Web 服务进行身份验证,而不是使用网络凭据或用户名/密码

【问题讨论】:

    标签: x509 exchangewebservices x509certificate2 x509securitytokenmanager


    【解决方案1】:

    我一直在使用这个没有错误

            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 2012-02-20
      相关资源
      最近更新 更多