[研究][ASP.NET]加簽寄信-值不能為 null。參數名稱: findValue
2022-06-07
環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#
********************************************************************************
把
//從Web.Config中抓Email憑證序號值 string emailCertificateSN = ConfigurationManager.AppSettings["EmailCertificateSN"]; //用 Email憑證序號抓比較不會抓錯 X509Certificate2 signCert = store.Certificates.Find(X509FindType.FindBySerialNumber, emailCertificateSN, false)[0]; |
改成下面,失敗直接
//從Web.Config中抓Email憑證序號值
string emailCertificateSN = ConfigurationManager.AppSettings["EmailCertificateSN"];
if (emailCertificateSN == null || emailCertificateSN == "")
{
return "讀取不到Email憑證序號。";
}
//用 Email憑證序號抓比較不會抓錯
X509Certificate2 signCert = store.Certificates.Find(X509FindType.FindBySerialNumber, emailCertificateSN, false)[0];
|
(完)
沒有留言:
張貼留言