我正在尝试迁移使用pkcs12证书(cert + key)调用后端点的代码。我在.net中这样做:
string PKSC12_SELFCERTPATH = "http://...";
string SELFCERTPWD = "Ipp@9999"
var handler = null;
try
{
var cert = new X509Certificate2(PKSC12_SELFCERTPATH, SELFCERTPWD);
handler = new WebRequestHandler();
handler.ClientCertificates.Add(cert);
var client = new HttpClient(handler);
System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(ValidarCertificado);
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
var values = new Dictionary<string, string>
{
{ "appId", LITERAL_APPID },
{ "secret",LITERAL_SECRET }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync( URL, content);
var responseString = await response.Content.ReadAsStringAsync();
json = JObject.Parse(responseString);
}
catch(Exception ex)
{
...
}
我们正在使用此库(https://github.com/encharm/x509.js),但是它与crt文件一起使用,¿我们是否需要首先使用密码将我的pkcs12手动导出到crt?