远程方关闭传输流时身份验证失败

时间:2017-10-04 10:57:29

标签: .net exchange-server imap .net-framework-version sslstream

我正在尝试使用我的.NET 4.0应用程序中的IMAP连接到Exchange服务器。以下是我遇到的问题:

var host = "mail.mydomain.com";
var port = 993;
var tcpClient = new TcpClient(host, port);
var stream = new SslStream(tcpClient.GetStream(), false, (sender, cert, chain, e) => true, null);
stream.AuthenticateAsClient(host); // => IOException here

我在最后一行得到Authentication failed because remote party has closed the transport stream 我已经尝试过使用下面的解决方法而没有运气:

  • ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;  
    
  • 将目标框架更改为.NET 4.5并尝试:

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls| SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
    
  • SchUseStrongCrypto中添加了HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319注册表项并重新启动。

但是,如果我将程序的目标框架更改为.NET 2.0,则相同的代码可以正常工作。 我的程序托管在Windows Server 2008 R2上。

0 个答案:

没有答案