【问题标题】:The specified CGI application encountered an error and the server terminated the process. azure指定的 CGI 应用程序遇到错误,服务器终止了进程。天蓝色
【发布时间】:2017-06-19 08:43:26
【问题描述】:

我在我的 asp.net 核心 API 中添加了一个 mastercard sdk。对 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();
            }
        }

【问题讨论】:

  • 您是否在 Google 上搜索过您的错误消息?它带来了一些有希望的结果。
  • 哦,是的。但仍然没有运气
  • 我很惊讶,甚至编译。我找不到在第二个参数中采用字节数组的OAuthAuthentication 的重载。您是否尝试过使用 .p12 文件的路径而不是从资源中读取它?
  • 是的。我现在有点接近了。我认为这是一个超时问题。

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


【解决方案1】:

查看C#的MasterCard SDK的源代码后,我发现,当我们调用OAuthAuthentication时,它会创建一个X509Certificate2的实例。错误是在这一行引起的。

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

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

【讨论】:

    猜你喜欢
    • 2018-05-17
    • 1970-01-01
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 2018-12-24
    • 2019-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多