Я пытаюсь сделать запрос на получение с взаимной аутентификацией
Возникла некоторая проблема с HTTPS Handshake
Я использовал fiddler, чтобы посмотреть, что отправлено на сервер, и посмотреть ответ от него
Запрос:
CONNECT test.api.bgw.baltics.sebgroup.com:443 HTTP/1.1
Host: test.api.bgw.baltics.sebgroup.com
A SSLv3-compatible ClientHello handshake was found. Fiddler extracted the parameters below.
Version: 3.3 (TLS/1.2)
Random: 5E A8 0A E9 DB 60 E1 45 5E 08 3B 58 DC A2 EA D3 11 6F 22 1D 8D D5 51 F2 47 56 E5 54 B6 AB 9D 80
"Time": 23/11/2093 06:43:10
SessionID: empty
Extensions:
server_name test.api.bgw.baltics.sebgroup.com
supported_groups x25519 [0x1d], secp256r1 [0x17], secp384r1 [0x18]
ec_point_formats uncompressed [0x0]
signature_algs rsa_pkcs1_sha256, rsa_pkcs1_sha384, rsa_pkcs1_sha1, ecdsa_secp256r1_sha256, ecdsa_secp384r1_sha384, ecdsa_sha1, dsa_sha1, rsa_pkcs1_sha512, ecdsa_secp521r1_sha512
SessionTicket empty
extended_master_secret empty
renegotiation_info 00
Ciphers:
[C02C] TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
[C02B] TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
[C030] TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
[C02F] TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[009F] TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
[009E] TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
[C024] TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
[C023] TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
[C028] TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
[C027] TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
[C00A] TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
[C009] TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
[C014] TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
[C013] TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
[009D] TLS_RSA_WITH_AES_256_GCM_SHA384
[009C] TLS_RSA_WITH_AES_128_GCM_SHA256
[003D] TLS_RSA_WITH_AES_256_CBC_SHA256
[003C] TLS_RSA_WITH_AES_128_CBC_SHA256
[0035] TLS_RSA_WITH_AES_256_CBC_SHA
[002F] TLS_RSA_WITH_AES_128_CBC_SHA
[000A] SSL_RSA_WITH_3DES_EDE_SHA
Compression:
[00] NO_COMPRESSION
Ответ от сервера:
HTTP/1.1 200 Connection Established
FiddlerGateway: Direct
StartTime: 13:52:25.353
Connection: close
fiddler.network.https> HTTPS handshake to test.api.bgw.baltics.sebgroup.com (for #7) failed.
System.IO.IOException Unable to read data from the transport connection:
An existing connection was forcibly closed by the remote host.
< An existing connection was forcibly closed by the remote host
У меня такой код:
try
{
ServicePointManager.DefaultConnectionLimit = 100;
ServicePointManager.Expect100Continue = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback += (message, cert, chain, errors) => true;
HttpClientHandler httpClientHandler = new HttpClientHandler();
httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
httpClientHandler.SslProtocols = SslProtocols.Tls12;
httpClientHandler.ServerCertificateCustomValidationCallback += (message, cert, chain, errors) => {
return true;
};
httpClientHandler.ClientCertificates.Add(new X509Certificate("EEBGWTEST.crt"));
HttpClient httpClient = new HttpClient(httpClientHandler);
//var result = httpClient.GetAsync("https://test.api.bgw.baltics.sebgroup.com/v1/accounts/EE211010220284954221/current-transactions").GetAwaiter().GetResult();
var requestMessage = new HttpRequestMessage(HttpMethod.Get, "https://test.api.bgw.baltics.sebgroup.com/v1/accounts/EE211010220284954221/current-transactions");
var result = httpClient.SendAsync(requestMessage).GetAwaiter().GetResult();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
if (ex.InnerException != null) MessageBox.Show(ex.InnerException.Message);
}
В чем может быть причина из-за этой ошибки?
Еще одна интересная вещь заключается в том, что, если я повторю запрос от fiddler, он вернется без ошибки
HTTP/1.1 200 Connection Established
FiddlerGateway: Direct
StartTime: 14:05:20.951
Connection: close
информация об услуге аутентификации для этого кода https://developer.baltics.sebgroup.com/bgw/docs/auth