Foxtable(狐表)用户栏目专家坐堂 → [求助]DownloadFile下载https的文件被拦截!


  共有2740人关注过本帖树形打印复制链接

主题:[求助]DownloadFile下载https的文件被拦截!

帅哥哟,离线,有人找我吗?
jerry727869905
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:79 积分:1030 威望:0 精华:0 注册:2012/11/19 16:03:00
[求助]DownloadFile下载https的文件被拦截!  发帖心情 Post By:2019/8/8 14:53:00 [只看该作者]

Network.DownloadFile批量下载某https网站的音频文件时,提示无法连接远程服务器。
经测试,浏览器是可以直接打开的,可能是https证书被拦截问题,请问各位大神如何解决?


文件举例:
https://mp3.91dict.com/mp32/99f7f92a5d41ace19be3d6876dfc872f/581.mp3?auth_key=1558656000-0-0-e56ad0673fee038e4d3c4761785dedbc



此主题相关图片如下:下载报错.png
按此在新窗口浏览图片


我查阅了相关的帖子,最相近的如下:
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=113876&skin=0

1、全局代码

 

Public Function CheckValidationResult(sender As Object, certificate As System.Security.Cryptography.X509Certificates.X509Certificate, chain As System.Security.Cryptography.X509Certificates.X509Chain, errors As System.Net.Security.SslPolicyErrors) As Boolean
 ' 总是接受    
 Return True
End Function

 

 

2、参考

 

dim bytes
dim requrl = "https://api.mch.weixin.qq.com/secapi/pay/refund"

Dim cert As String = "C:\cert\apiclient_cert.p12"
Dim password As String = "商户号"
System.Net.ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(addressof CheckValidationResult)

Dim cer As System.Security.Cryptography.X509Certificates.X509Certificate = New System.Security.Cryptography.X509Certificates.X509Certificate(cert, password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.MachineKeySet)
Dim webrequest As net.HttpWebRequest = net.HttpWebRequest.Create(reqUrl)
webrequest.ClientCertificates.Add(cer)
webrequest.Method = "post"

webrequest.ContentLength = bytes.Length
webrequest.GetRequestStream().Write(bytes, 0, bytes.Length)
Dim webreponse As Net.httpWebResponse = webrequest.GetResponse()
Dim stream As io.Stream = webreponse.GetResponseStream()
Dim resp As String = String.Empty
Using reader As io.StreamReader = New io.StreamReader(stream)
resp = reader.ReadToEnd()
End Using


但我还是不知如何修改,请诸位大神指导!谢谢!


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2019/8/8 15:05:00 [只看该作者]

你既然用foxtable,为啥要那么复杂,直接:

Dim hc As New HttpClient("https://mp3.91dict.com/mp32/99f7f92a5d41ace19be3d6876dfc872f/581.mp3?auth_key=1558656000-0-0-e56ad0673fee038e4d3c4761785dedbc")
If hc.GetFile("c:\data\123.mp3") Then
    MessageBox.show("文件下载成功","提示")
Else
    MessageBox.show("文件下载失败","提示")
End If

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2019/8/8 15:05:00 [只看该作者]

参考:
http://www.foxtable.com/mobilehelp/topics/0153.htm

 回到顶部
帅哥哟,离线,有人找我吗?
jerry727869905
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:79 积分:1030 威望:0 精华:0 注册:2012/11/19 16:03:00
  发帖心情 Post By:2019/8/8 19:05:00 [只看该作者]

哈哈,这么有幸,狐狸爸爸亲自为我解惑答疑图片点击可在新窗口打开查看图片点击可在新窗口打开查看图片点击可在新窗口打开查看
想不到原来这么方便,原来用downloadfile习惯了,一下子没想到,还是狐狸爸爸威武图片点击可在新窗口打开查看图片点击可在新窗口打开查看图片点击可在新窗口打开查看

 回到顶部