how to GET https content using client certificate

Andrus 121 Reputation points
2022-03-10T10:52:00.167+00:00

How to retrieve page over https using client and server certificate in .NET 6 C# ?

Using curl this works:

curl --no-progress-bar --silent --show-error -H "OrgId: 123456" --insecure --key private.key --cert server.crt https://example.com --output result.xml

How to convert this to C# ?

private.key file is text file in format

-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAxTvKy3WRPqli9ODpIcTb8Bhnxa2x+8xip/kWq...

server.crt is text file in format

-----BEGIN CERTIFICATE-----
MIIEnzCCAoegAwIBAgIIIJKu2MhhxF0wDQYJKoZIhvcNAQENBQAwLjEeMBwGA1UE

This is ASP.NET 6 MVC application running in Debian and Windows servers.

Developer technologies | .NET | Entity Framework Core
Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | ASP.NET | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.