V. *_*mma 8 certificate amazon-web-services asp.net-core aws-certificate-manager identityserver4
我正在尝试将ASP.NET Core 2 Web应用程序部署到AWS Elastic Beanstalk.
该应用程序实际上是IdentityServer4,我需要访问该认证才能签署和验证令牌.
有一个教程如何配置Azure的Web应用程序使用证书的位置,但我还没有发现AWS类似的事情.
无论我搜索AWS及其证书,我总能找到有关HTTPS的SSL/TLS连接的文章和文档.我知道如何做到并且将单独执行此操作,我已经在AWS Certificate Manager中提供了证书,我可以在Elastic Beanstalk中为Load Balancer设置它,但ACM文档声明:
因此,如果我想在我的代码中使用证书,那么ACM Cert似乎并不适用于此.
我可以使用OpenSSL创建自签名证书,但我不知道从Elastic Beanstalk实例中的ASP.NET Core 2 Web应用程序访问它的最佳方法是什么.我不能把证书文件放在我的代码库中,我想以某种方式通过AWS将它注入环境但我不知道在我的应用程序中何处或如何访问它?
我也花了一些时间寻找这个。
我最终所做的是将证书的 base64 和证书密码存储在 Secrets Manager 中,并在启动时使用Kralizek 的 AWSSecretsManagerConfigurationExtensions在应用程序中读取。
private X509Certificate2 CreateSigningCredential()
{
if (_signingCertificate != null)
return _signingCertificate;
var certBytes = Configuration.GetValue<string>("Auth:Certificate");
if (string.IsNullOrEmpty(certBytes))
{
return null;
}
var password = Configuration.GetValue<string>("Auth:CertificatePassword");
if (string.IsNullOrEmpty(password))
{
return null;
}
var certificate = Convert.FromBase64String(certBytes);
_signingCertificate = new X509Certificate2(certificate, password);
return _signingCertificate;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
492 次 |
最近记录: |