IdentityServer4 Error: well-known/openid-configuration: HTTPS required

When the client sends a connection request to identityserver4, an error is reported: HTTPS required

Error connecting to http://192.168.20.6:5601/.well-known/openid-configuration: HTTPS required

Since the identity server 4 project does not enable HTTPS, the client does not write it well

It was written like this at the beginning, using WinForm

string AuthorityAddress = ConfigurationManager.AppSettings["AuthorityAddress"];

var client = new HttpClient() ; 
var disco = await client.GetDiscoveryDocumentAsync(AuthorityAddress);

if (disco.IsError)
{
    LogHelper.LogError(disco.Error);
    return false;
}

report errors

Later, you can set the request policy through discoverydocument request

string AuthorityAddress = ConfigurationManager.AppSettings["AuthorityAddress"];

var client = new HttpClient() ; 
// var disco = await client.GetDiscoveryDocumentAsync(AuthorityAddress);

var config = new DiscoveryDocumentRequest() { Address = AuthorityAddress, Policy = new DiscoveryPolicy() { RequireHttps = false } };
var disco = await client.GetDiscoveryDocumentAsync(config);

if (disco.IsError)
{
    LogHelper.LogError(disco.Error);
    return false;
}

In our development environment, sometimes we don’t care whether it’s HTTP or HTTPS. When we deploy, we find that there are many problems.

You need to issue a certificate to deploy HTTPS. If you use intranet, just deploy HTTP directly


Read More: