Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ae0673b

Browse filesBrowse files
committed
Fixed sample
1 parent 82db14c commit ae0673b
Copy full SHA for ae0673b

File tree

Expand file treeCollapse file tree

2 files changed

+19
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-11
lines changed

‎snippets/csharp/System.Net.Http/WinHttpHandler/Project.csproj

Copy file name to clipboardExpand all lines: snippets/csharp/System.Net.Http/WinHttpHandler/Project.csproj
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
</PropertyGroup>
7-
7+
8+
<ItemGroup>
9+
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="9.0.6" />
10+
</ItemGroup>
11+
812
</Project>
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
using System;
22
using System.Net;
33
using System.Net.Http;
4-
using System.Net.Sockets;
5-
using System.Threading.Tasks;
4+
using System.Net.Security;
65

76
class WinHttpHandler_SecureExample
87
{
9-
static async Task Main()
8+
static void Main()
109
{
10+
if (!OperatingSystem.IsWindows())
11+
{
12+
Console.WriteLine("This example requires Windows.");
13+
return;
14+
}
1115
// <Snippet1>
1216
var handler = new WinHttpHandler();
13-
handler.ServerCertificateValidationCallback = (httpRequestMessage, certificate, chain, sslPolicyErrors)
17+
handler.ServerCertificateValidationCallback = (httpRequestMessage, certificate, chain, sslPolicyErrors) =>
1418
{
15-
if (sslPolicyErrors == SslPolicyErrors.None)
19+
if (sslPolicyErrors == SslPolicyErrors.None)
20+
{
21+
// TODO: Implement additional custom certificate validation logic here.
1622
return true;
17-
18-
Console.WriteLine("Certificate error: {0}", sslPolicyErrors);
19-
23+
}
2024
// Do not allow this client to communicate with unauthenticated servers.
2125
return false;
22-
}
26+
};
2327
// </Snippet1>
2428
}
2529
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.