0

I am running my Windows Service on Ubuntu 14 with mono service.

When my service tries to connect with SSL connection, it's throwing the following Exception:

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

I tried the solutions from the following posts and tried to ignore the Exception, but none of them were helpful in my case:

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

EDIT: This is my connection code:

 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 is a Global Class that contains the needed variables.

I cannot connect to server. But when I start this server on my Windows, it works just fine. It is supposed to send and receive XML message as bytes.

What do you suggest?

Community
  • 1
  • 1
FireFalcon
  • 831
  • 11
  • 23

1 Answers1

1

Try to replace this line:

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

with this:

 var ssl_stream = new SslStream(csGlobal.m_tcp_client.GetStream());
firefalcon
  • 500
  • 2
  • 8
  • 21