指定的CGI应用中遇到一个错误,该服务器终止该进程。蔚蓝
问题描述:
我添加了一个万事达卡SDK来我的asp.net核心API。在我的本地机器上调用api工作正常。但是当部署在azure上时会引发上述错误。指定的CGI应用中遇到一个错误,该服务器终止该进程。蔚蓝
我已经尝试了一切。
我附上一个调试器对活动网站。当我打电话 SetAuthentication
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。
你Google的错误讯息?它带来了一些有希望的结果。 – Crowcoder
哦,是的。但仍没有运气 – maxspan
我很惊讶,甚至编译。我找不到在第二个参数中需要一个字节数组的“OAuthAuthentication”重载。你有没有尝试使用您的.p12文件的路径,而不是从资源中读取它? – Crowcoder