我已将 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/