c# - 指定的 CGI 应用程序遇到错误,服务器终止了该进程。 azure 的

标签 c# azure asp.net-core-mvc

我已将 mastercard sdk 添加到我的 asp.net core api 中。对 api 的调用在我的本地计算机上运行良好。但是当部署在azure上时,它会抛出上述错误。

我已经尝试了一切。

我已将调试器附加到实时站点。当我调用时它会抛出错误 设置身份验证

public MatchType RequestCall(string consumerKey, string keyAlias, string keyPassword)
    {
        byte[] certificateBytes = GetCertificateStream();
        ApiConfig.SetAuthentication(new OAuthAuthentication(consumerKey, certificateBytes, keyAlias, keyPassword));
        ApiConfig.SetSandbox(true);

        RequestMap map = GenerateRequestMap();
        TerminationInquiryRequest response = TerminationInquiryRequest.Create(map);
        return GetMatchType(response);

    }



 public byte[] GetCertificateStream()
        {
            var resourceName = typeof(TerminationMatchInquiry).GetTypeInfo().Assembly.GetManifestResourceNames()[0];//Get certificate resource name
            using (Stream CertStream = typeof(TerminationMatchInquiry).GetTypeInfo().Assembly.GetManifestResourceStream(resourceName))
            {
                byte[] RawBytes = new byte[CertStream.Length];
                for (int Index = 0; Index < CertStream.Length; Index++)
                {
                    RawBytes[Index] = (byte)CertStream.ReadByte();
                }
                return RawBytes.ToArray();
            }
        }

最佳答案

审核MasterCard SDK的来源后对于 C#,我发现,当我们调用 OAuthAuthentication 时,它会创建 X509Certificate2 的实例。错误是由这一行引起的。

cert = new X509Certificate2(rawCertificateData, password, keyStoreFlags | X509KeyStorageFlags.Exportable);

在Azure WebApp中,如果我们尝试使用证书,我们需要从Azure门户上传证书。在 Azure WebApp 应用程序中添加带有指纹值的 WEBSITE_LOAD_CERTIFICATES。更多详细信息请引用blog .

关于c# - 指定的 CGI 应用程序遇到错误,服务器终止了该进程。 azure 的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44625897/

相关文章:

c# - 找不到不同程序集中的 ASP.NET Core ViewComponents

javascript - 无法在 asp.net core 中使用 ajax 将 json 发布到 Controller

c# - 通过 2TB 文件的文件偏移量随机读取许多 300 字节 block 的最快方法?

c# - Xamarin.Forms FontAwesome 不适用于绑定(bind)属性

c# - 将 Firefox 中 Places.sqlite 文件中的日期转换为 DateTime

.net - azure webapp 无法启动 : Could not find 'aspnetcorev2_inprocess.dll' . 您 > 必须安装或更新 .NET 才能运行此应用程序

azure - Microsoft Expression Encoder 许可的命令行脚本

azure - 在 Salesforce APEX 中实现 Azure Put Blob

c# - 使用 C# 从 excel 写入文本文件

c# - 具有依赖注入(inject)的 MVC 6 自定义模型绑定(bind)器