2023-06-20 13:26:14 +02:00

32 lines
849 B
Plaintext

== How to fix it in .NET
=== Code examples
In the following example, the callback change impacts the entirety of HTTP
requests made by the application.
:cert_method_name: ServerCertificateValidationCallback
include::../../common/fix/code-rationale-override.adoc[]
==== Noncompliant code example
[source,vbnet]
----
Imports System.Net
Public Sub Send()
ServicePointManager.ServerCertificateValidationCallback =
Function(sender, certificate, chain, errors) True ' Noncompliant
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(New System.Uri("https://example.com"))
request.Method = System.Net.WebRequestMethods.Http.Get
Dim response As System.Net.HttpWebResponse = request.GetResponse()
response.Close()
End Sub
----
=== How does this work?
include::../../common/fix/validation.adoc[]