C# 无法使用HttpWebRequest连接到HTTPS代理
当我尝试使用HttpWebRequest连接到HTTPS代理时,我遇到以下错误:C# 无法使用HttpWebRequest连接到HTTPS代理,c#,ssl,proxy,C#,Ssl,Proxy,当我尝试使用HttpWebRequest连接到HTTPS代理时,我遇到以下错误:ServicePointManager不支持使用HTTPS方案的代理。有简单的解决方法吗?以下是失败的代码示例: namespace TestProxy { class Program { static void Main(string[] args) { var proxyUrl = "https://proxyhost:8888";
ServicePointManager不支持使用HTTPS方案的代理。
有简单的解决方法吗?以下是失败的代码示例:
namespace TestProxy
{
class Program
{
static void Main(string[] args)
{
var proxyUrl = "https://proxyhost:8888";
var proxy = new WebProxy(proxyUrl, false);
var request = (HttpWebRequest) WebRequest.Create("http://targethost:80");
request.Proxy = proxy; // NotSupportedException
}
}
}
使用TcpClient(类似于)可以实现这一点,但我想使用HttpWebRequest,它为我做了很多工作。否则,我将不得不用HTTPS支持重新创建它