尝试通过 运行 window 应用程序时从网络服务收到无法验证您的身份的错误

Your identity could not be authenticated error received from web service when try through run window application

我正在开发 window 服务,我需要调用使用 x509 证书类型安全性进行身份验证的 Web 服务。

现在我通过导入 .pfx 和 .crt 文件然后导出 .cer 文件在我的系统上生成了 .cer 文件。我在 VS2015 中使用它来与 Web 服务进行通信。

它工作正常。然后,如果我在同一系统上创建设置并安装但在下面给出错误。网络服务返回的错误

"error_name" : "authentication_failure",
    "error_advice" : "Your identity could not be authenticated. This may mean that your request was not accompanied with your Client Certificate, or your software does not have access to your Private Key in order to encrypt messages correctly. Please check your software's configuration and associated file permissions for both your Client Certificate and Private Key. In addition, please check that your software supports secure connections using TLS 1.2 or higher."

早些时候,当我尝试在 visual studio 中进行调试时,我使用下面的代码加载 .cer,它工作正常

X509Certificate certificate = X509Certificate.CreateFromCertFile(ConfigurationManager.AppSettings["CertificateFilePath"].ToString()); 

并在 app.config

<add key="CertificateFilePath" value="E:\ZooplaCerts\test\zooplasandbox_cert.cer"/>

现在,当我创建设置和安装 运行 window 服务时,出现上述错误

我已尝试将代码更改为以下内容

var certificate = new X509Certificate2(ConfigurationManager.AppSettings["CertificateFilePath"].ToString(), string.Empty, X509KeyStorageFlags.MachineKeySet);

但仍然出现同样的错误。然后我尝试从服务中更改 Log On Type 并选择 Local System Account 但仍然是相同的错误

尝试通过安装

运行 window 服务时收到错误
"error_name" : "authentication_failure",
    "error_advice" : "Your identity could not be authenticated. This may mean that your request was not accompanied with your Client Certificate, or your software does not have access to your Private Key in order to encrypt messages correctly. Please check your software's configuration and associated file permissions for both your Client Certificate and Private Key. In addition, please check that your software supports secure connections using TLS 1.2 or higher."

我现在一切正常当我尝试从 .pfx 为本地系统帐户创建一个新的 .cer 文件并将 window 服务登录选项设置为本地系统时