【问题标题】:Asp.net on-premises authentication - The remote certificate is invalid according to the validation procedureAsp.net 本地身份验证 - 根据验证程序,远程证书无效
【发布时间】:2016-10-21 12:06:18
【问题描述】:

因此,我正在与我们的系统管理员合作,为我们在这里开发的 Web 工具设置本地身份验证(使用 ADFS)。

我已经完成了设置过程,当我运行项目时出现异常:

“根据验证程序,远程证书无效。”

   [AuthenticationException: The remote certificate is invalid according to the   validation procedure.]
   System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) +231
   System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) +15
   System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) +119

现在,当我将这段代码插入 StartupAuth.cs 时,我能够真正到达登录页面

   ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateCertificate);
...

static bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
   return true;
}

但是在登录时,系统抛出了另一个异常。而且我们不想总是验证证书。有趣的是,当系统管理员切换到自签名证书时,我们甚至无法访问登录页面。我们正在使用通配符证书,但我想知道这是否是问题所在。

我们的系统管理员认为我们可能只需要购买一个正确签名的证书,但我想知道我是否存在配置问题。

编辑:在进一步调查中,我收到了一条有意义的错误消息。这是调试输出(我已将证书序列号和 URL 替换为“xxx”):

Looking at Security Cert. Issuers...
    System.Security.Cryptography.X509Certificates.X509Chain
    CN=xxxxx.xxxx.org
    Checking elements in X509 Chain:
    UntrustedRoot
    A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.

【问题讨论】:

    标签: asp.net authentication ssl


    【解决方案1】:

    通过将 ADFS 服务器上的证书安装到我的开发机器上的“受信任的根证书颁发机构”下,我们已经能够解决安全证书问题。

    【讨论】:

      猜你喜欢
      • 2016-12-20
      • 2011-03-28
      • 2016-11-28
      • 1970-01-01
      • 2013-08-08
      • 2012-07-20
      • 2015-03-17
      相关资源
      最近更新 更多