【发布时间】: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