方法1:
X509Certificate2 x509 = new X509Certificate2(strPathPfx, strPasswordPfx);
改為X509Certificate2 x509 = new X509Certificate2(strPathPfx.ToString(), strPasswordPfx.ToString(), X509KeyStorageFlags.MachineKeySet)
方法2:
IIS應用池》高階設定 》修改載入使用者配置檔案 》True
原文連結:https://blog.csdn.net/qq_34894585/article/details/108386960