首页 新闻 会员 周边

WebClient.UpLoadData 方法怎么想 https打头的URI上传文件。

0
悬赏园豆:10 [已解决问题] 解决于 2020-08-06 09:01

如题:
查询到的WebClient.UpLoadData方法都是类似这种地址。
string uristring = “http://localhost/login.aspx”;
现在想要向
string uristring = “https://localhost/login.aspx”;这种地址上传。
程序报错
webclient.uploaddata Could not establish trust relationship for the SSL/TLS secure channel
无法连接。
想请教下怎么解决,或者说,WebClient.UpLoadData就支持不了https的地址。

几个酒菜成这样的主页 几个酒菜成这样 | 初学一级 | 园豆:187
提问于:2020-06-03 17:04
< >
分享
最佳答案
0

因为你用的是自己生成的证书. 百度一下 "Could not establish trust relationship for the SSL/TLS secure channel" 你就能得到答案

收获园豆:10
czd890 | 专家六级 |园豆:14412 | 2020-06-04 10:26

感谢大佬回答额。
搜索了大约是增加一个:
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);

private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true; //总是接受
}
这类方法,来通过验证。
确实发生了变化。原来是报“The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.”这个错误。
增加了之后变成了“the remote server returnd an error:(404) not found”这个错误。
不太能理解还有什么问题?是服务器的问题导致连不上吗?

几个酒菜成这样 | 园豆:187 (初学一级) | 2020-06-04 15:21

@几个酒菜成这样: 404 这更加不用解释了呀。哈哈

czd890 | 园豆:14412 (专家六级) | 2020-06-06 01:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册