单声道服务异常 - 身份验证或解密失败

时间:2014-11-01 10:22:20

标签: c# ssl mono ubuntu-14.04 mono-service

我在Ubuntu 14上使用单声道服务运行我的Windows服务。

当我的服务尝试连接SSL连接时,它会抛出以下异常:

The authentication or decryption has failed.
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0

我尝试了以下帖子中的解决方案,并试图忽略异常,但在我的情况下,它们都没有帮助:

Mono https webrequest fails with "The authentication or decryption has failed"

c# - "The authentication or decryption has failed." error while using twitterizer in mono

The authentication or decryption has failed.

authentication or decryption has failed when sending mail to GMail using SSL

编辑: 这是我的连接代码:

 ServicePointManager.ServerCertificateValidationCallback += CertificateValidationCallBack;
 csGlobal.m_tcp_client = new TcpClient(csGlobal.m_hostname, csGlobal.m_port);

 var ssl_stream = new SslStream(csGlobal.m_tcp_client.GetStream(), false, (sender, certificate, chain, ssl_policy_errors) => ssl_policy_errors == SslPolicyErrors.None);

 var ssl_reader = new StreamReader(csGlobal.m_tcp_client.GetStream());
 ssl_stream.AuthenticateAsClient(csGlobal.m_hostname);
 ssl_stream.ReadTimeout = (int)csGlobal.READ_TIMEOUT.TotalMilliseconds;

 csGlobal.m_ssl_stream = ssl_stream;

csGlobal是一个包含所需变量的全局类。

我无法连接到服务器。但是,当我在Windows上启动此服务器时,它运行正常。它应该以字节形式发送和接收XML消息。

你有什么建议?

1 个答案:

答案 0 :(得分:1)

尝试替换此行:

 var ssl_stream = new SslStream(csGlobal.m_tcp_client.GetStream(), false, (sender, certificate, chain, ssl_policy_errors) => ssl_policy_errors == SslPolicyErrors.None);

用这个:

 var ssl_stream = new SslStream(csGlobal.m_tcp_client.GetStream());