2014-11-01 76 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());