I am trying to make a simple request GETto an external production server with a client certificate. They added our certificate to their server, and I successfully made requests through Postman (both the Chrome application and the native Windows application) and through standard browsers:

The version of the Postman app for Chrome uses the built-in certificate search from Chrome. For a native Postman application, I need a .crt and .key file, which I extracted from my .p12 file .
In other words, the certificate was successfully found in the repository, and also works when used from files (in the native Windows application, assuming that this is possible in .NET).
Getting a certificate in C #
# (.NET Framework 4.5.1) ( ) ( , ):
private static X509Certificate2 GetCertificate(string thumbprint)
{
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection coll =
store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint,
validOnly: true);
X509Certificate2 certificate = coll.Count == 0 ? null : coll[0];
return certificate;
}
HttpClient HttpWebRequest:
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3;
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12;
X509Certificate cert = GetCertificate(thumbprint);
string url = "https://sapxi.example.com/XISOAPAdapter/MessageServlet";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.ClientCertificates.Add(cert);
request.Method = WebRequestMethods.Http.Get;
WebResponse basicResponse = request.GetResponse();
string responseString = new StreamReader(basicResponse.GetResponseStream()).ReadToEnd();
HttpClient HttpWebRequest :
(WebException) : .
(IOException) : .
(SocketException)
Visual Studio
, , , ( ):
System.Net Error: 0 : [29136] Can't retrieve proxy settings for Uri 'https:
System.Net Information: 0 : [29136] Associating HttpWebRequest
System.Net Information: 0 : [29136] Associating Connection
System.Net.Sockets Information: 0 : [29136] Socket
System.Net Information: 0 : [29136] Connection
System.Net Information: 0 : [29136] TlsStream
System.Net Information: 0 : [29136] Associating HttpWebRequest
System.Net Information: 0 : [29136] HttpWebRequest
System.Net Information: 0 : [29136] ConnectStream
{
Host: sapxi.example.com
Connection: Keep-Alive
}.
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] Enumerating security packages:
System.Net Information: 0 : [29136] Negotiate
System.Net Information: 0 : [29136] NegoExtender
System.Net Information: 0 : [29136] Kerberos
System.Net Information: 0 : [29136] NTLM
System.Net Information: 0 : [29136] TSSSP
System.Net Information: 0 : [29136] pku2u
System.Net Information: 0 : [29136] WDigest
System.Net Information: 0 : [29136] Schannel
System.Net Information: 0 : [29136] Microsoft Unified Security Protocol Provider
System.Net Information: 0 : [29136] Default TLS SSP
System.Net Information: 0 : [29136] CREDSSP
System.Net Information: 0 : [29136] SecureChannel
*my certificate is here* (Issuer = CN=TRUST2408 OCES CA II, O=TRUST2408, C=DK)
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] SecureChannel
*my certificate is here*
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent = Outbound, scc = System.Net.SecureCredential)
System.Net Information: 0 : [29136] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = sapxi.example.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [29136] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=171, returned code=ContinueNeeded).
System.Net Information: 0 : [29136] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 278cca8:6d23888, targetName = sapxi.example.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [29136] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded).
System.Net Information: 0 : [29136] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 278cca8:6d23888, targetName = sapxi.example.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [29136] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded).
System.Net Information: 0 : [29136] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 278cca8:6d23888, targetName = sapxi.example.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [29136] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded).
System.Net Information: 0 : [29136] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 278cca8:6d23888, targetName = sapxi.example.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [29136] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=CredentialsNeeded).
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] SecureChannel
*my certificate is here*
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] SecureChannel
*my certificate is here*
System.Net Information: 0 : [29136] SecureChannel
System.Net Information: 0 : [29136] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent = Outbound, scc = System.Net.SecureCredential)
System.Net Information: 0 : [29136] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 278cca8:6d23888, targetName = sapxi.example.com, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [29136] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=349, returned code=ContinueNeeded).
System.Net.Sockets Error: 0 : [29136] Socket
System.Net.Sockets Error: 0 : [29136] Exception in Socket
System.Net Error: 0 : [29136] Exception in HttpWebRequest
, , , . URL IP .
, . 8 . , .
to
X509Certificate2 .
, HttpWebRequests .
, .
Wireshark
Wireshark Postman #, , , , Client Verify ( ) #, Postman ( ).
Postman :

# :

, .
(//request.ClientCertificates.Add(cert)), Wireshark, , , . Visual Studio Left with 0 client certificates to choose from. - .
, Wireshark , Postman TLS1.2 - TLS1.2.
-,
, , IIS Express , .
Request.ClientCertificates.
wirehark Verify, - - .
, , IIS Express . , .
, , , , - , , - , HttpWebRequest # 't .
- / ( , , / )
- .key .crt,
HttpClient SendAsync() WebRequestHandler- .NET Framework 4.6.1
- .NET Framework 4.7.1
- TLS 1.2 (
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12) request.ClientCertificates.Add(serverCert)- WinHttpCertCfg.exe,
- Visual Studio
- :
.
ServicePointManager.ServerCertificateValidationCallback =
(sender, certificate, chain, sslPolicyErrors) =>
{
return true;
};
ServicePointManager.Expect100Continue = true;
request.AllowAutoRedirect = true;
request.PreAuthenticate = true;
request.KeepAlive = false;
request.UserAgent = null;
request.CachePolicy = new HttpRequestCachePolicy(
HttpCacheAgeControl.MaxAge, TimeSpan.FromSeconds(0));
, SAP XI, , . , , , , . , - .
, ASP-/API ( ) .
, HttpClient.
, , , , Postman.
. .
, , :
GET SAP XI , TLS 1.2 #?
, , URL- IP- . , , . , . , , .
/ , , , , .
, , , . .
, , , , .
.