dotnet / dotnet/dotnet-api-docs

ServicePointManager.ServerCertificateValidationCallback documentation should state that the eventhandler is not thread safe

Open
#3,745 0 comments 0 reactions 0 assignees View on GitHub
area-System.Net doc-enhancement Pri3
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

[ServicePointManager](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Net/ServicePointManager.xml)
```
void Main()
{
List tList = new List();

for (int i = 0; i < 100000; i++)
{
tList.Add(Task.Run(() =>
{
try
{
ServicePointManager.ServerCertificateValidationCallback += CertificateValidationCallback;
}
finally
{
ServicePointManager.ServerCertificateValidationCallback -= CertificateValidationCallback;
}
}));
}

Task.WaitAll(tList.ToArray());

ServicePointManager.ServerCertificateValidationCallback?.Invoke(new object(), new X509Certificate(), null, System.Net.Security.SslPolicyErrors.None);

}

private static bool CertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
Console.WriteLine("Test");
return true;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.