.NET App Failing URL Fetch Due to TLS/SSL Handshake Issue?

Muhammad Huzaifa 0 Reputation points
2025-12-03T15:06:13.6466667+00:00

I’m building a small .NET console tool that sends periodic GET requests to my website Modern Food Cateringand I’m noticing that the request occasionally fails with a TLS/SSL handshake error (AuthenticationException). The site loads fine in Chrome, so I’m unsure whether this is related to .NET’s TLS version defaults or server-side configuration.

Is there a recommended way to debug or enforce specific TLS versions in .NET to ensure consistent connectivity?

Developer technologies | .NET | .NET CLI
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-12-03T15:06:26.0466667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To address the TLS/SSL handshake issue you're experiencing with your .NET console tool, here are some recommended steps:

    1. Check .NET Framework Version: Ensure that your application targets a .NET Framework version that supports the latest TLS protocols. Versions prior to 4.7 may default to TLS 1.0, which is not secure. It's recommended to upgrade to at least .NET Framework 4.6 or later, or set the appropriate registry keys for 'UseStrongCrypto' if you're using older versions.
    2. Defer to OS Default TLS Version: In your application, you can specify that it should use the operating system's default TLS version by setting the EnabledSslProtocols property to None. This allows your application to automatically use the most recent version of TLS available on the OS, which can help avoid compatibility issues.
    3. Inspect Handshake Messages: Use tools like Wireshark or tcpdump to capture and analyze the TLS handshake messages. This can help you identify whether the client and server are negotiating a common cipher suite and TLS version.
    4. Check Cipher Suites: Ensure that the server supports the cipher suites your application is attempting to use. On Windows, you can configure cipher suites using PowerShell cmdlets like Enable-TlsCipherSuite and Disable-TlsCipherSuite.
    5. Handle Exceptions: Implement proper exception handling in your application to manage AuthenticationException and other related exceptions. This will help you log detailed error messages and troubleshoot further.

    By following these steps, you should be able to debug the TLS/SSL handshake issues and enforce specific TLS versions as needed.


    References:

    0 comments No comments

  2. Varsha Dundigalla(INFOSYS LIMITED) 3,725 Reputation points Microsoft External Staff
    2025-12-04T08:48:23.73+00:00

    Thank you for reaching out.
    If your .NET app fails with TLS/SSL handshake errors, it usually means the client and server don’t agree on protocol or cipher. Modern servers often require TLS 1.2 or TLS 1.3. Older .NET versions may default to weaker protocols.

    Steps to fix:

    • Enable strong crypto for .NET Framework Add this in App.config under <runtime>:
        <AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=false" />
      
      Or set registry key:
        [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319] "SchUseStrongCrypto"=dword:00000001
      
    • Force TLS 1.2 in .NET Framework (if needed)
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
      
    • For .NET Core / .NET 5+ Defaults use OS strong crypto. If you must pin:
        handler.SslOptions.EnabledSslProtocols = SslProtocols.Tls12;
      
    • Server-side checks Enable TLS 1.2 or TLS 1.3, disable TLS 1.0/1.1, use modern cipher suites (AES-GCM). Make sure the certificate chain is complete and trusted.
    • Debugging Use Wireshark or openssl s_client -connect host:443 to confirm supported protocols and ciphers.

    Please let us know if you require any further assistance, we’re happy to help.

    If you found this information useful, kindly mark this as "Accept Answer".

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.