== How to fix it in .NET

=== Code examples

==== Noncompliant code example

These samples use a default TLS algorithm, which is a weak cryptographical
algorithm: TLSv1.0.

[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Imports System.Net
Imports System.Security.Authentication
                
Public Sub Encrypt()
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls ' Noncompliant
End Sub
----

[source,vbnet,diff-id=2,diff-type=noncompliant]
----
Imports System.Net.Http
Imports System.Security.Authentication
                
Public Sub Encrypt()
    Dim Handler As New HttpClientHandler With { 
        .SslProtocols = SslProtocols.Tls ' Noncompliant
    }
End Sub
----

==== Compliant solution

[source,vbnet,diff-id=1,diff-type=compliant]
----
Imports System.Net
Imports System.Security.Authentication
                
Public Sub Encrypt()
    ServicePointManager.SecurityProtocol = _
        SecurityProtocolType.Tls12 _
        Or SecurityProtocolType.Tls13
End Sub

----

[source,vbnet,diff-id=2,diff-type=compliant]
----
Imports System.Net.Http
Imports System.Security.Authentication
                
Public Sub Encrypt()
    Dim Handler As New HttpClientHandler With { 
        .SslProtocols = SslProtocols.Tls12
    }
End Sub
----

=== How does this work?

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