== How to fix it in .NET

=== Code examples

==== Noncompliant code example

These samples use TLSv1.0 as the default TLS algorithm, which is cryptographically weak.

[source,csharp,diff-id=1,diff-type=noncompliant]
----
using System.Net;

public void encrypt()
{
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; // Noncompliant
}
----

[source,csharp,diff-id=2,diff-type=noncompliant]
----
using System.Net.Http;
using System.Security.Authentication;

public void encrypt()
{
    new HttpClientHandler
    {
        SslProtocols = SslProtocols.Tls // Noncompliant
    };
}
----

==== Compliant solution

[source,csharp,diff-id=1,diff-type=compliant]
----
Using System.Net;

public void encrypt()
{
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
}
----

[source,csharp,diff-id=2,diff-type=compliant]
----
using System.Net.Http;
using System.Security.Authentication;

public void encrypt()
{
    new HttpClientHandler
    {
        SslProtocols = SslProtocols.Tls12
    };
}
----

=== How does this work?

include::../../common/fix/fix.adoc[]
