gpt4 book ai didi

c# - 尝试通过运行窗口应用程序时,无法验证从 Web 服务接收到的身份错误

转载 作者:太空宇宙 更新时间:2023-11-03 15:10:02 25 4
gpt4 key购买 nike

我正在处理窗口服务,我需要调用使用 x509 证书类型安全性进行身份验证的 Web 服务。

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

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

"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"/>

现在,当我创 build 置并安装和运行窗口服务时,出现上述错误

我尝试将代码更改为以下

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

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

尝试通过安装运行窗口服务时收到错误

"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 文件并将窗口服务登录选项设置为本地系统时,我现在一切正常

关于c# - 尝试通过运行窗口应用程序时,无法验证从 Web 服务接收到的身份错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41648585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com