Home > Net >  Centos7 run asp Core HttpClient SSL error appeared
Centos7 run asp Core HttpClient SSL error appeared

Time:09-21

 string url=$" https://api.weixin.qq.com/sns/oauth2/access_token? Appid={appid} & amp; Secret={appSecret} & amp; Code={code} & amp; Grant_type=authorization_code "; 

Var. Client=_httpClientFactory CreateClient ();
Var response=await client. SendAsync (new HttpRequestMessage (HttpMethod. The Get url));
if (! The response. IsSuccessStatusCode) return null;
Var result=await the response. The content. ReadAsStringAsync ();
OauthTokenResult accessToken=JsonConvert. DeserializeObject (result);
_logger. LogWrite ($" access authorization AccessToken: {result} ");
return accessToken;


 2020/02/29 20:16:48. 081 | ERROR |=======================================================================
User IP: 119.44.61.188
Page anomalies: https://api.barendao.com/api/AccessToken/WeChat
Error sources: System.Net.Http
Abnormal information: The SSL connection could not be established, see inner exception.
The exception stack:
At System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (Stream, Stream, SslClientAuthenticationOptions sslOptions, CancellationToken CancellationToken)
The at System.Net.Http.HttpConnectionPool.ConnectAsync (HttpRequestMessage request, Boolean allowHttp2, CancellationToken CancellationToken)
The at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync (HttpRequestMessage request, CancellationToken CancellationToken)
The at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync (HttpRequestMessage request, CancellationToken CancellationToken)
The at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (HttpRequestMessage request, Boolean doRequestAuth, CancellationToken CancellationToken)
The at System.Net.Http.RedirectHandler.SendAsync (HttpRequestMessage request, CancellationToken CancellationToken)
The at System.Net.Http.DiagnosticsHandler.SendAsync (HttpRequestMessage request, CancellationToken CancellationToken)
At Microsoft. Extensions. Http. Logging. LoggingHttpMessageHandler. SendAsync (HttpRequestMessage request, CancellationToken CancellationToken)
At Microsoft. Extensions. Http. Logging. LoggingScopeHttpMessageHandler. SendAsync (HttpRequestMessage request, CancellationToken CancellationToken)
The at System.Net.Http.HttpClient.FinishSendAsyncBuffered (Task 1 sendTask `, HttpRequestMessage request, CancellationTokenSource CTS, Boolean disposeCts)
The at Barendao. WeChat. OAuths. OAuthHandler. GetOauthTokenAsync (String appID, String appSecret, String code) in E: \ \ canxinSoft \ PrintingNet \ SRC \ V2 Utility \ Barendao WeChat \ OAuths \ OAuthHandler cs: line 33
The at Barendao. WebApi. Controllers. AccessTokenController. Login (WeChatLoginModel model) in E: \ canxinSoft \ PrintingNet \ SRC \ V2 \ Barendao WebApi \ Controllers \ AccessTokenController cs: line 56
The at lambda_method (Closure, Object)
At Microsoft. Extensions. Internal. ObjectMethodExecutorAwaitable. Awaiter. GetResult ()
At Microsoft. AspNetCore. Mvc. Proceeds. ActionMethodExecutor. AwaitableObjectResultExecutor. Execute (IActionResultTypeMapper mapper, ObjectMethodExecutor executor, the Object controller, Object [] the arguments)
At Microsoft. AspNetCore. Mvc. Proceeds. ControllerActionInvoker. & lt; InvokeActionMethodAsync> G__Awaited | 12 _0 (ControllerActionInvoker invoker, ValueTask ` 1 actionResultValueTask)
At Microsoft. AspNetCore. Mvc. Proceeds. ControllerActionInvoker. & lt; InvokeNextActionFilterAsync> 10 _0 g__Awaited | (ControllerActionInvoker invoker, Task lastTask, State next, and the Scope the Scope, Object State, Boolean isCompleted)
At Microsoft. AspNetCore. Mvc. Proceeds. ControllerActionInvoker. Rethrow (ActionExecutedContextSealed context)
At Microsoft. AspNetCore. Mvc. Proceeds. ControllerActionInvoker. Next (State& Next, Scope& The scope, Object& The state, Boolean& IsCompleted)
At Microsoft. AspNetCore. Mvc. Proceeds. ControllerActionInvoker. & lt; InvokeInnerFilterAsync> G__Awaited | 13 _0 (ControllerActionInvoker invoker, Task lastTask, State next, and the Scope the Scope, Object State, Boolean isCompleted)
At Microsoft. AspNetCore. Mvc. Proceeds. ResourceInvoker. & lt; InvokeNextExceptionFilterAsync> 25 _0 g__Awaited | (ResourceInvoker invoker, Task lastTask, State next, and the Scope the Scope, Object State, Boolean isCompleted)
=======================================================================

CodePudding user response:

The
refer to the original poster canxinzyts response:
...
Abnormal information: The SSL connection could not be established, see inner exception .
.

Exception information to let you see specific InnerException,
You can also provide other information,
Netcore version, for example,
On the Windows machine debugging is normal, for example,
Such as on Centos whether can normal curl https://api.weixin.qq.com/sns/oauth2
And on and on...

There is a possible Centos7 certificate container, not set is normal, no trust api.weixin.qq.com the issuer of the certificate used,
Another possibility is netcore configuration, container, cause we do not have the right to use HttpClient certificate

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C #
  • Related