Sam Afshari's Notes
  • GitHub
  • Twitter/X
  • Booklets
    • Ray Tracing & Rendering
    • Command & Conquer: Generals Engine
    • Doom Source Code
    • Wolfenstein 3D Source Code
  • All posts
  • Ed
  • NuGets
  • POIWorld
  • RedCorners

Mono Frustrations: "The authentication or decryption has failed."

Wed, Jul 1, 2015

Often calling the AuthenticateAsClient method of an SslStream results in the “The authentication or decryption has failed.” error, because Mono cannot verify the certificate. As a last resort, the error can be circumvented by disabling the certificate validation by adding the following line to the code:

ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;

If you are creating the SslStream in a using block, you can do this instead:

using (SslStream s = new SslStream(tcpClient.GetStream(), false, new RemoteCertificateValidationCallback((o, certificate, chain, errors) => true)))
{
    s.AuthenticateAsClient(uri.Host, null, SslProtocols.Tls, false);
    ...
}

Back to Home


© Sam Afshari 2026