- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每次我尝试通过 VS2015 和 IIS Express 在我的开发盒上运行我的 MVC 项目时,我都会收到一个错误。它使用此代码对我们的 ADFS 服务器进行身份验证。
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = realm,
MetadataAddress = adfsMetadata
});
这是我在浏览器中遇到的错误。
[AuthenticationException: The remote certificate is invalid accordingto the validation procedure.]
System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) +231
System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) +15
System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) +119[WebException: The underlying connection was closed: Could notestablish trust relationship for the SSL/TLS secure channel.]
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)+606 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)+64[HttpRequestException: An error occurred while sending the request.]
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()+28 Microsoft.IdentityModel.Protocols.d__0.MoveNext()+453[IOException: Unable to get document from:https://adfs.DOMAIN.com/FederationMetadata/2007-06/FederationMetadata.xml]Microsoft.IdentityModel.Protocols.d__0.MoveNext()+830 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() +28 Microsoft.IdentityModel.Protocols.<GetAsync>d__1.MoveNext() +606 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()+28 Microsoft.IdentityModel.Protocols.d__3.MoveNext()+1332[InvalidOperationException: IDX10803: Unable to create to obtainconfiguration from:'https://adfs.DOMAIN.com/FederationMetadata/2007-06/FederationMetadata.xml'.]Microsoft.IdentityModel.Protocols.d__3.MoveNext()+2226 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()+28 Microsoft.Owin.Security.WsFederation.d__c.MoveNext()+772 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Security.Infrastructure.d__b.MoveNext()+447 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Security.Infrastructure.d__8.MoveNext()+440 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Security.Infrastructure.d__5.MoveNext()+266 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +1174 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext()+287 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +937 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext()+287 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Tasktask) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Tasktask) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()+26 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__2.MoveNext()+272 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26 Microsoft.Owin.Host.SystemWeb.Infrastructure.ErrorState.Rethrow() +33Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResultar) +150
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResultar) +42
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResultar) +9791593
最佳答案
再次感谢 Thuan 的回答。
从答案中,我能够思考到底发生了什么(这对于弄清楚事情总是至关重要的)。关键是意识到问题源于远程证书未通过验证检查,而没有其他原因。所以我发现在 UseWsFederationAuthentication 调用中有一个 BackchannelCertificateValidator 选项,可用于验证证书是否有效。然后我找到了这个 post这帮助我想出了验证证书的代码。
该帖子从 Microsoft 站点 ( https://msdn.microsoft.com/en-us/library/office/dd633677(v=exchg.80).aspx ) 中找到了他们的代码。在文章中,它说明了有关代码的内容。
The certificate validation callback method in this example provides sufficient security for development and testing of EWS Managed API applications. However, it may not provide sufficient security for your deployed application. You should always make sure that the certificate validation callback method that you use meets the security requirements of your organization.
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
BackchannelCertificateValidator = new CertificateValidator(),
Wtrealm = realm,
MetadataAddress = adfsMetadata
});
}
public class CertificateValidator : ICertificateValidator
{
public bool Validate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
// If the certificate is a valid, signed certificate, return true.
if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
{
return true;
}
// If there are errors in the certificate chain, look at each error to determine the cause.
if ((sslPolicyErrors & System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors) != 0)
{
if (chain != null && chain.ChainStatus != null)
{
foreach (System.Security.Cryptography.X509Certificates.X509ChainStatus status in chain.ChainStatus)
{
if ((certificate.Subject == certificate.Issuer) &&
(status.Status == System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.UntrustedRoot))
{
// Self-signed certificates with an untrusted root are valid.
continue;
}
else
{
if (status.Status != System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
// If there are any other errors in the certificate chain, the certificate is invalid,
// so the method returns false.
return false;
}
}
}
}
// When processing reaches this line, the only errors in the certificate chain are
// untrusted root errors for self-signed certificates. These certificates are valid
// for default Exchange server installations, so return true.
return true;
}
else
{
// In all other cases, return false.
return false;
}
}
}
关于asp.net-mvc - UseWsFederationAuthentication - AuthenticationException : The remote certificate is invalid according to the validation procedure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39734173/
我们想在应用商店中发布一个应用。为我们构建它的第 3 方需要我们通过苹果开发门户创建的证书和配置文件。根据文档,创建证书的方法是使用 mac 的钥匙串(keychain)应用程序,然后选择“从证书颁发
我正在尝试使用 Java Http 客户端连接到服务器以进行 Web 服务调用。如果我用下面的代码打开网络调试.. System.setProperty("javax.net.debug", "all
我在尝试推送我的更改时才开始收到此错误。我不知道我的系统发生了什么变化,并且在这方面不应该有任何自签名证书。 Git 已卸载并重新安装。 Git 似乎使用了正确的包: http.sslcainfo=C
除非我设置以下内容,否则我会收到上述错误: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 这是不安全的,违背了 SSL 的目的。 我已经从 http
我有一个基于 Linux 的 Docker 容器,如果我这样做: curl https://google.com ...然后我得到一个错误: curl: (60) SSL certificate pr
我想在我的 Linux 计算机上安装 nvm。(我的 Debian 版本是 10,Git 版本是 2.27。OPENSSL 版本是 1.1.1d 2019 年 9 月 10 日) 我阅读了这份文件 h
我正在使用 Symfony 5,我需要使用 composer 安装 'knplabs/knp-snappy-bundle' 但我有这个消息: [Composer\Downloader\Transpor
我已经通过 VSTS 部署我的应用程序一段时间了,然后突然出现此错误: 无法访问 SSL 证书问题:(url) 证书链中的自签名证书。 为什么突然发生这种情况,我该如何解决? 更新:我注意到我有一个新
我正在尝试使用安全性配置 WCF 服务。我生成了 2 个存储在 LocalComputer\Personal Certificates 中的证书(用于服务器和客户端)。我的配置是: 服务器:
我正在创建连接到的 Azure 函数来执行 PnP 命令。我已经创建了 docs 中提到的证书。我总是收到Cannot findcertificate with this指纹在证书存储中。Except
美好的一天,我是服务器设置的新手。我目前正在使用 laravel 5.4 来集成我的 quickbooks app在我的实时服务器上 http://qb.dagnum.com/connect但我继续收
我正在尝试从 Github 克隆一个项目但我无法克隆它,因为我有这个错误 无法访问:SSL 证书问题:证书链中的自签名证书 我可以从我的网络访问并且我有证书。 我的Android Studio有什么问
我正在尝试使用 AWS-CLI 检索 aws elasticbeanstalk 详细信息,但出现以下错误。 错误信息: C:\abdul>aws elasticbeanstalk describe-e
我实际上正在阅读有关证书和证书链的内容。我了解证书是由实体的私钥签名的一段数据,只能使用给定实体(例如根 CA)的公钥解密。 但是,我在几个地方看到“证书签署另一个证书”(例如:Microsoft I
我想默认“接受”新证书。我尝试了以下方法。 $ dpkg-reconfigure -f noninteractive ca-certificates 它运行,但没有添加 CA。 如果不行,直接修改/e
有人通过AWS Certificate Manager为他们的域名购买了通配符证书,我需要将其转移到Heroku,以获取使用域名子域名的应用程序。 无论是通过AWS控制台还是通过其CLI,我都找不到如
我可以通过重新启动我的 Windows 7 来运行 selenium 服务器。但是,如果我终止服务器并再次启动它,我将收到此错误。有时执行 webdriver-manager update--igno
我在 IE9 中遇到安全证书问题。 然后我去我得到的特定地址 There is a problem with this website's security certificate. 如何避免出现此窗
应用签名证书和上传证书有什么区别? 我在将 Google Play 游戏与我的应用程序集成时遇到了问题(我将此作为另一个问题发布),我注意到用于在 Google API 控制台上自动生成的客户端 ID
我正在尝试在 Mac 上使用 Heroku CLI。 当我尝试使用 Heroku login 登录 Heroku 并提供我的凭据时,出现以下错误: Error: self signed certifi
我是一名优秀的程序员,十分优秀!