小弟最近搞HttpWebRequest,普通的Http是不再话下了,于是研究了下https,对于ssl下在页面并提交数据很是头大啊。
也从网上找了点资料,参照着资料就写了点代码试了试。[测试链接 https://passport.baidu.com/?reg& ]
先贴下代码 public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
private void SendData()
{
postData = "";
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(IsTrust);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://passport.baidu.com/?reg");
System.Net.ServicePointManager.Expect100Continue = false;
request.CookieContainer = cookies;//cookies里面存着get --https://passport.baidu.com/?reg&的cookies
//其余 的代码和普通的http一样
}返回的页面内容很是困惑,跟get是一模一样的。又看看嗅探器(小弟用的是HttpAnaly5).发现我提交的数据自动复制了一次,所有的参数都是出现两次,对比正常的提交,发现并没有少什么东西。https服务器也没有报 不能建立信任之类的异常,只是和get后的页面一样,好像并没有提交一样,可是我确定我的request的Method是post。这让我非常困惑,也没找到很好的资料,所以来这里问问高手们,这是怎么回事?小弟感激不尽
也从网上找了点资料,参照着资料就写了点代码试了试。[测试链接 https://passport.baidu.com/?reg& ]
先贴下代码 public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
private void SendData()
{
postData = "";
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(IsTrust);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://passport.baidu.com/?reg");
System.Net.ServicePointManager.Expect100Continue = false;
request.CookieContainer = cookies;//cookies里面存着get --https://passport.baidu.com/?reg&的cookies
//其余 的代码和普通的http一样
}返回的页面内容很是困惑,跟get是一模一样的。又看看嗅探器(小弟用的是HttpAnaly5).发现我提交的数据自动复制了一次,所有的参数都是出现两次,对比正常的提交,发现并没有少什么东西。https服务器也没有报 不能建立信任之类的异常,只是和get后的页面一样,好像并没有提交一样,可是我确定我的request的Method是post。这让我非常困惑,也没找到很好的资料,所以来这里问问高手们,这是怎么回事?小弟感激不尽
tpl_ok
skip_ok
aid
need_pay
need_coin
pay_method
u ./
next_target
return_method get
more_param
friend
uid
rand
nick
crypt b3862af80e4e185cef97c13b
k192668125 1292079337
regin 0
username xabctev
loginpass 413149260
verifypass 413149260
sex 1
email [email protected]
verifycode x3rntpl=
tpl_ok
skip_ok
aid
need_pay
need_coin
pay_method
u ./
next_target
return_method get
more_param
friend
uid
rand
nick
crypt b3862af80e4e185cef97c13b
k192668125 1292079337
regin 0
username xabctev
loginpass 413149260
verifypass 413149260
sex 1
email [email protected]
verifycode x3rn这是嗅探器看出来提交的数据,我不明白为什么我提交的单份数据会出现两次。很是困惑,而且服务器并没有报 未能建立信任,我觉的肯能不单单是证书的问题,可就是想不来,高手help me 啊。