新文章 网摘 文章 随笔 日记

ids4生产环境部署https openssl(身份服务器4)

1,生成证书:
需要密码》
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650
或者
不需要密码
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650
2,导出证书未pfx格式
openssl pkcs12 -export -in cert.pem -inkey key.pem -out ids4.pfx
要求输入证书密码(lanhu)

从剪贴板

 

3,使用证书
keyFilePath =“ c:\ ids4.pfx”
builder.AddSigningCredential(new X509Certificate2(keyFilePath,keyFilePassword));
 
1,********************************* https-https
客户端应用:
认证中心:
 
2,**************************************** http-http
客户端应用:
认证中心:
 
3,**************************************** http-https
客户端应用:
认证中心:
有这个提示:
您在此页面上输入的信息将通过不安全的连接发送,并且可能被第三方读取。
您确定要发送此信息吗?
 
****************************************************** ****************************************************** ***********************
 
问题:
集成身份认证数据库时:
“ DBConnString”:“数据源= .;初始目录= IdentityServer4;集成安全性= SSPI;”
用户'IIS APPPOOL \ admin'登录失败。原因:基于令牌的服务器访问验证失败,出现基础结构错误。请检查以前的错误
在IIS管理器中-》应用程序池-》 ASP.NETV4.0 ————》高级设置-》标识-》替换本地系统
 
证书路径问题:
 
2020-08-03 14:17:45.049 +08:00 [FTL]未处理的异常:未配置签名凭证。
System.InvalidOperationException:未配置签名证书。
在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeAsync(ValidatedAuthorizeRequest请求)处
在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateHybridFlowResponseAsync(ValidatedAuthorizeRequest请求)处
在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest请求)
在IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection参数,ClaimsPrincipal用户,ConsentResponse同意)处
在IdentityServer4.Endpoints.AuthorizeCallbackEndpoint.ProcessAsync(HttpContext上下文)处
在IdentityServer4.Endpoints.AuthorizeCallbackEndpoint.ProcessAsync(HttpContext上下文)处
在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件,IBackChannelLogoutService backChannelLogoutService)
2020-08-03 14:17:45.049 +08:00 [ERR]执行请求时发生未处理的异常。
System.InvalidOperationException:未配置签名证书。
在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateCodeAsync(ValidatedAuthorizeRequest请求)处
在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateHybridFlowResponseAsync(ValidatedAuthorizeRequest请求)处
在IdentityServer4.ResponseHandling.AuthorizeResponseGenerator.CreateResponseAsync(ValidatedAuthorizeRequest请求)
在IdentityServer4.Endpoints.AuthorizeEndpointBase.ProcessAuthorizeRequestAsync(NameValueCollection参数,ClaimsPrincipal用户,ConsentResponse同意)处
在IdentityServer4.Endpoints.AuthorizeCallbackEndpoint.ProcessAsync(HttpContext上下文)处
在IdentityServer4.Endpoints.AuthorizeCallbackEndpoint.ProcessAsync(HttpContext上下文)处
在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件,IBackChannelLogoutService backChannelLogoutService)
在IdentityServer4.Hosting.IdentityServerMiddleware.Invoke处(HttpContext上下文,IEndpointRouter路由器,IUserSession会话,IEventService事件,IBackChannelLogoutService backChannelLogoutService)
在IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke处(HttpContext上下文,IAuthenticationSchemeProvider方案)
在Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext上下文)
在IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext上下文)
主机意外终止。
 
证书权限问题:
Internal.Cryptography.CryptoThrowHelper + WindowsCryptographicException:出现了内部错误。
 
在Internal.Cryptography.Pal.CertificatePal.FilterPFXStore处(字节[] rawData,SafePasswordHandle密码,PfxCertStoreFlags pfxCertStoreFlags)
 
在Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile(Byte [] rawData,String fileName,SafePasswordHandle password,X509KeyStorageFlags keyStorageFlags)中
 
在System.Security.Cryptography.X509Certificates.X509Certificate..ctor(字符串文件名,字符串密码,X509KeyStorageFlags keyStorageFlags)
 
在System.Security.Cryptography.X509Certificates.X509Certificate2..ctor中(字符串fileName,字符串密码)
解决方法:(不需要应用标识更改LocalSystem,ApplicationPoolIdentity就行
1,设置IIS用户和IUser有证书pfx所在目录的权限
2,mmc导入pfx证书,自动类型
3,约会的时候指定参数
builder.AddSigningCredential(新X509Certificate2(keyFilePath,keyFilePassword,X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet));
 
****************************************************** **********************************************
初始调用:X509Certificate2证书=新的X509Certificate2(input.Path,CER_PASSWORD);
相关译文:
MachineKeySet被描述为“私钥存储在本地计算机存储中而不是当前用户存储”。没有标志的替代值是放在用户存储中。
即使您正在从磁盘上读取证书插入其存储在对象中,私钥仍存储在Microsoft加密API加密服务提供程序密钥数据库中。在托管服务器上,ASP.NET进程没有访问用户存储的权限。
有两个可能原因(我两个问题都遇到了):
1.权限不足

解决方法:提升程序池权限为LocalSystem,如下图

从剪贴板

2.秘钥没有读取到,提示:出现了内部错误
修改了X509Certificate2声明后,提示“权限不足”,X509Certificate2如下声明:
X509Certificate2证书=新的 X509Certificate2(input.Path,CER_PASSWORD,X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);
然后按照,第一种解决方法即可。
 
PS:注意没有安装证书的,需要先双击证书文件


 

 

 
.net网站&系统开发技术学习交流群:533829726
本站文章除注明转载外,取代本站原创或翻译,欢迎任何形式的转载,但请注明出处,关于人工劳动,共创和谐网络环境。
转载请注明:文章转载自:蓝狐软件工作室» ids4生产环境部署HTTPS OpenSSL的(身份服务器4)
本文标题:ids4生产环境部署HTTPS OpenSSL的(身份服务器4)
本文地址:HTTP://www.lanhusoft.com/Article/774.html
posted @ 2020-10-14 16:03  岭南春  阅读(374)  评论(0)    收藏  举报