当前位置:   article > 正文

IdentityServer4 The remote certificate is invalid according to the validation procedure._identityserver4用自签名证书报错

identityserver4用自签名证书报错

问题描述:

项目涉及到过等保,被要求增加https协议访问,于是在我的单点登录站点增加了自签名的证书,部署成功支持了HTTPS的访问。单点登录使用的是IdentityServer4集成的。我的其他服务没有支持https协议,而其他服务在验证token合法性时,需要先从单点登录服务去发现相关文档,https://192.168.20.209:8023/.well-known/openid-configuration 这个接触过IdentityServer4的应该都比较熟悉了,问题是通过这个地址去拉取信息时报错,信息如下:

fail: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[0]
2022-03-22T06:14:12.050767868Z       IDX20803: Unable to obtain configuration from: 'https://192.168.20.209:8023/.well-known/openid-configuration'.
2022-03-22T06:14:12.050770538Z System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://192.168.20.209:8023/.well-known/openid-configuration'.
2022-03-22T06:14:12.050772704Z  ---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'https://192.168.20.209:8023/.well-known/openid-configuration'.
2022-03-22T06:14:12.050774835Z  ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
2022-03-22T06:14:12.050776825Z  ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
2022-03-22T06:14:12.050778863Z    at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)

可以得知说是单点登录的证书无效,不合法不安全之类的,通过浏览器访问这个地址是可以的,问题就比较明白了,请求之前进行了双向验证,我们只需要在请求之前跳过验证就行了,那么如何跳过呢,找到验证token的相关代码,参考代码如下:

有些同学用的是 AddJwtBearer

关于这个Handler的注释说的是用于检索元数据的HttpMessageHandler。

The HttpMessageHandler used to retrieve metadata. This cannot be set at the same time as BackchannelCertificateValidator unless the value is a WebRequestHandler.

 八九不离十就是配置它了。

配置完毕,发布升级。哇咔咔验证通过。

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/448793
推荐阅读
相关标签
  

闽ICP备14008679号