While requesting to HCP server (PUT file) i got error "ErrorMessage: The SSL connection could not be established, see inner exception" with description "Authentication failed because the remote party sent a TLS alert: 'HandshakeFailure'"
It's everything ok when i try it using postman:
I created console app to test it (8.0) and try few methods:
RestSharp:
var options = new RestClientOptions("https://...")
{
MaxTimeout = -1,
FollowRedirects = false,
};
var client = new RestClient(options);
var request = new RestRequest($"...", Method.Put);
request.AddHeader("Authorization", "...");
request.AddHeader("Content-Type", "application/pdf");
request.AddParameter("application/pdf", attachment, ParameterType.RequestBody);
RestResponse response = await client.ExecuteAsync(request);
HttpRequestMessage:
var client3 = new HttpClient();
var request3 = new HttpRequestMessage(HttpMethod.Put, "...");
request3.Headers.Add("Authorization", "...");
request3.Content = new StreamContent(File.OpenRead("..."));
var response3 = await client3.SendAsync(request3);
response3.EnsureSuccessStatusCode();
var response3Content = await response3.Content.ReadAsStringAsync();
HttpWebRequest:
HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create(url);
request2.Method = WebRequestMethods.Http.Put;
request2.AllowWriteStreamBuffering = false;
request2.SendChunked = true;
request2.AllowAutoRedirect = false;
request2.Headers.Add("Authorization", "...");
using (Stream dataStream = request2.GetRequestStream())
{
using (MemoryStream fileStreamToRead = new MemoryStream(attachment))
{
fileStreamToRead.CopyTo(dataStream);
}
}
var response2 = (HttpWebResponse)request2.GetResponse();
I get this error every time. I try to set:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13;
And
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
But any of them dont help. Only in combination Tls13 and HttpWebRequest i got another error:
The client and server cannot communicate, because they do not possess a common algorithm
How to resolve the problem and what postman doing background what fix it?