A exceção de postagem da API do núcleo .net fornece NativeErrorCode 12175
para o código abaixo, ele captura um HttpRequestException / System.Net.Http.WinHttpException quando chamado
a exceção declara: NativeErrorCode 12175
Mensagem "Ocorreu um erro de segurança"
1.ConfiguredTaskAwaiter.GetResult() at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext() --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult () em System.Net.Http.HttpClient.d__58.MoveNext () --- Fim do rastreamento de pilha do local anterior onde a exceção foi lançada --- em System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (tarefa Task) em System.Runtime.CompilerServices.TaskAwaiter`1.GetResult () em Controllers.Controller.d__0.MoveNext ()mas usando o Postman no mesmo endpoint, recurso, cabeçalhos e corpo, recebo 200 de volta.
POST /account/ HTTP/1.1
Host: test-org.com
X-HTTP-Method-Override: GET
Content-Type: application/xml
Cache-Control: no-cache
Postman-Token: ce565d1a-bfb7-0961-ffd7-d279b90e97c5
<?xml version="1.0" encoding="UTF-8"?>
<accountMessage xmlns="http://sdfssd
........
</accountMessage>
quando eu faço uma pesquisa no google por NativeErrorCode 12175 .NET, encontro o seguinte:https://msdn.microsoft.com/en-us/library/windows/desktop/aa383770(v=vs.85).aspx
ERROR_WINHTTP_SECURE_FAILURE
12175
One or more errors were found in the Secure Sockets Layer (SSL) certificate sent by the server. To determine what type of error was encountered, check for a WINHTTP_CALLBACK_STATUS_SECURE_FAILURE notification in a status callback function. For more information, see WINHTTP_STATUS_CALLBACK.
Código quebrado:
// GET: api/Accounts
[HttpGet]
public async Task<IActionResult> Get()
{
try
{
using (var client = new HttpClient())
{
try
{
client.BaseAddress = new Uri("https://test-org.com/");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "account");
request.Content = new StringContent("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<accountMessage xml...</accountMessage>",Encoding.UTF8,"application/xml");
request.Headers.Add("X-HTTP-Method-Override", "GET");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync();
var posts = JsonConvert.DeserializeObject<IEnumerable<Post>>(stringResponse);
if (posts == null) return NotFound($"Posts were not found");
return Ok(posts);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Request exception: {e.Message}");
}
}
}
catch (Exception)
{
}
return BadRequest();
}