小编Rak*_*mar的帖子

X509Certificate2错误-系统找不到指定的文件

关联的代码在独立的控制台应用程序中运行良好,而在尝试使其正常运行的同时,却在NSB体系结构中出错。我试过在worker中进行相同的测试,也尝试在测试控制台应用程序中进行独立测试。无论哪种情况,它都会出错-X509Certificate2证书=新的X509Certificate2(filePath,“ *** key *** UeUHFxS”); 异常消息-System.Security.Cryptography.CryptographicException:'系统找不到指定的文件。该代码包括一个,如图所示,还包括一个与Activate设备相关的帮助文件。但是,从pfx文件路径和密钥初始化X509Certificate2的部分例外。

class Program
{
    static void Main(string[] args)
    {
        try
        {
            string filePath = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory);
            filePath = Directory.GetParent(Directory.GetParent(filePath).FullName).FullName;
            filePath = Path.Combine(filePath, @"Cert\TestCompany-qa.partner.client.siriusxm.com.pfx");

            X509Certificate2 certificate = new X509Certificate2(filePath, "****key****");
            SoapMessageHelper soapHelper = new SoapMessageHelper(certificate, @"https://api-ext-test.siriusxm.com/SAT/UpdateDeviceSatRefresh/v_1");
            var test = soapHelper.ActivateDevice(new ActivateDeviceRequest()
            {
                SourceName = "12493",
                ESN = "W26890HW",
                TimeStamp = DateTime.UtcNow,
                TrasanctionId = System.Guid.NewGuid().ToString()
            });

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(test);

            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                foreach (XmlNode locNode in node)
                {
                    if (locNode.Name == "ns0:responseRefreshDevice") …
Run Code Online (Sandbox Code Playgroud)

c# asp.net nservicebus x509certificate2 x509

1
推荐指数
2
解决办法
3918
查看次数

标签 统计

asp.net ×1

c# ×1

nservicebus ×1

x509 ×1

x509certificate2 ×1