我有一些微服务。一个是 IdentityServer 的微服务通过 HTTPS 运行,我还有第二个微服务是一个受保护的 API,它使用 HTTP(我无法更改它)
这是受保护的 API(客户端凭据流)
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = "https://localhost:5001";
options.RequireHttpsMetadata = false;
options.ApiName = "NotifyAPI";
options.ApiSecret = "api_secret";
});
它无法从 http 发出 https 请求
连接到https://localhost:5001/.well-known/openid-configuration时出错。无法建立 SSL 连接,请参阅内部异常。
此方法有效,但我无法在身份验证配置(Startup.cs)中更改 HttpClientHandler
using (var httpClientHandler = new HttpClientHandler())
{
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =>
{
return true;
};
using (var client = new HttpClient(httpClientHandler))
{
var response = await client.GetAsync("https://localhost:5001/.well-known/openid-configuration");
return response;
}
}