I have some microservices. One microservice which is IdentityServer runs over HTTPS, I also have a second microservice which is a protected API and it uses HTTP(I can’t change it)
This is protected API(Client credentials flow)
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = "https://localhost:5001";
options.RequireHttpsMetadata = false;
options.ApiName = "NotifyAPI";
options.ApiSecret = "api_secret";
});
It can't make a https request from http
Error connecting to https://localhost:5001/.well-known/openid-configuration. The SSL connection could not be established, see inner exception.
This method works, but I can't change HttpClientHandler in the Authentication configuration(Startup.cs)
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;
}
}