2014-11-01 124 views
1

我在带有单声道服务的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

试图取代这一行:

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());