我已带上证书请求了,但是还是出现问题。我使用VS工具调试时,可以正常进行退款,但发布到IIS上就出现远程服务器返回错误: 400 错误的请求,代码如下:
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
if (errors == SslPolicyErrors.None)
{
return true;
}
else
{
return false;
}
}
*********************************************以下为发起退款请求代码内容******************************************************
byte[] bs = Encoding.UTF8.GetBytes(data);
string cert = @"D:\eg\Dge5\apiclient_cert.p12"; //绝对路径,且已安装证书
string key = "1111111";//密
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
X509Certificate cer = new X509Certificate(cert, key);
HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url);
webrequest.ClientCertificates.Add(cer);
webrequest.Method = "POST";
webrequest.ContentType = "application/x-www-form-urlencoded";
webrequest.ContentLength = bs.Length;
//提交请求数据
Stream reqStream = webrequest.GetRequestStream();
reqStream.Write(bs, 0, bs.Length);
reqStream.Close();
//接收返回的页面
WebResponse wr = webrequest.GetResponse();//到了这一步就返回400错误的请求结果了
********************************************************************************************************************************
请问有人知道具体是哪里的问题么?
你好,我也遇到同样情况了,请问是怎么解决的?
证书创建除了地址,密码之外,还应该有个参数——证书存放模式,例如:
Dim cert As X509Certificate2 = New X509Certificate2(CertPath, CertPassword, X509KeyStorageFlags.MachineKeySet)
应用程序池高级设置中,找下加载用户配置文件,然后设为true
请问是我这里请求时,证书带入不成功?还是IIS没有权限问题?