我需要从Azure功能访问证书.
我按照Azure函数中的运行时错误加载证书中列出的步骤进行了操作,但它没有成功.
private static X509Certificate2 GetCertificate(string thumbprint, TraceWriter log)
{
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
try
{
store.Open(OpenFlags.ReadOnly);
log.Info("Enumerating certificates");
foreach (var cert in store.Certificates) {
log.Info(cert.Subject);
}
var col = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
if (col == null || col.Count == 0)
{
return null;
}
return col[0];
}
finally
{
store.Close();
}
Run Code Online (Sandbox Code Playgroud)
}
上传到Azure功能的两个证书和设置WEBSITE_LOAD_CERTIFICATES也被添加,并设置为*或所需证书的thumpbrint,但无济于事.
GetCertificate方法应该打印商店中所有证书的列表,但商店是空的.
关于如何解决这个问题的任何线索?
突然之间,无需部署或进行任何其他环境更改,我们就得到了
磁盘空间不足。在System.Security.Cryptography.CryptographicException.ThrowCryptographicException(mscorlib,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089)在System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(mscorlib,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089)在System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(mscorlib,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089)在System.Security.Cryptography.X509Certificates.X509 Certificate2..ctor(系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089)在[我们的代码]
有了这一行:
var certificateByes = Convert.FromBase64String(clientCertificateBody);
factory.Credentials.ClientCertificate.Certificate = new X509Certificate2(certificateByes);
Run Code Online (Sandbox Code Playgroud)
我正在努力了解在 Azure Web 应用程序的上下文中这会如何突然发生变化。我们上次部署是在 11 月 20 日,昨天开始抛出。这个基本功能已经使用了几个月,没有出现任何问题。
我们之前确实在这方面遇到过麻烦,我们正在读取的字符串是从密钥库中检索的,但同样,这里没有任何改变。
我在这里和这里读到了不同类型的错误,但我们的错误消息是不同的,而且这几个月来一直运行良好。
这是否与应用程序运行的时间或填充某些临时存储位置的其他缓存问题有关?