获取令牌时出错 "The remote certificate is invalid according to the validation procedure"

Error when get token "The remote certificate is invalid according to the validation procedure"

有许多类似的主题具有相同的问题,但与我在身份服务器上的问题无关。 可能我仍然无法理解这一点。 我正在尝试通过重新创建 this sample

来实现身份服务器身份验证

Sample GetToken() method 工作正常,但是当我在我的应用程序中调用 GetToken() 方法时出现错误

The remote certificate is invalid according to the validation procedure. I am realy not sure how semple working fine, but my code does not.

这是代码

public async Task<ActionResult> GetToken()
{
    var client = new TokenClient(
        "https://localhost:44331/connect/authorize",
        "codeclient",
        "secret");

    var code = Request.QueryString["code"];
    var tempState = await GetTempStateAsync();
    Request.GetOwinContext().Authentication.SignOut("TempState");

    var response = await client.RequestAuthorizationCodeAsync(
        code,
        "http://localhost/UniSrv.Client.Web/callback"
            );

    //... more code
   }

它在 RequestAuthorizationCodeAsync 中断。 我在 identiy 服务器主机应用程序上使用相同的证书作为示例应用程序。 我需要客户端证书吗?如果是,为什么不使用示例应用程序呢? 感谢您帮助解决此问题。

看起来 SSL 证书验证失败。尝试在回调端点上使用 HTTPS。 注意:使用 OAuth/OpenId 连接令牌时,必须启用 https 传输安全性。