user2102508
user2102508

Reputation: 1017

ServicePointManager doesn't support https proxy?

I have a problem requesting HTTPS service over the internet on some client, when I try to do it the exception is thrown that "The ServicePointManager doesn't support proxies with the https scheme". On some clients my code works fine, but on some it fails with the exception. I think customers for whom the code works fine have http proxy, and https traffic comes through the http proxy, which is perfectly fine.

This function creates a new request:

var req = (HttpWebRequest)WebRequest.Create(url);

// This thing is needed to get default proxy
// and user credentials written in iexplore
var proxy = req.Proxy;
if(proxy != null) {
    var puri = proxy.GetProxy(req.RequestUri);
    var prox = new WebProxy(puri.ToString());

    prox.Credentials = CredentialCache.DefaultCredentials;
    req.UseDefaultCredentials = true;
    req.Proxy = prox;
}

// Setting up custom cookies and UA
req.CookieContainer = Config.Cookies;
req.UserAgent = Config.UserAgent;

This is how I'm accepting all certificates:

ServicePointManager.ServerCertificateValidationCallback = 
(sender, cert, chain, sslpolicy) => true;

It seems that ServicePointManager doesn't infact support working with proxies over https. How can I fix this issue? What if I somehow make the https WebRequest go through the http proxy instead of https, will this work, if so how can I do it?

Upvotes: 0

Views: 6690

Answers (1)

Ihtsham Minhas
Ihtsham Minhas

Reputation: 1515

Yes, you are right, It seems like The ServicePointManager does not support proxies of the https scheme.

If you change the scheme from HTTPS to HTTP it will work fine.

It's only an initial request between the client and proxy that is not secure or over SSL. The traffic tunneled through the proxy is encrypted or no depending on the server.

If you are trying to access any SSL server through the HTTP proxy, the traffic is still encrypted.

Let say if you are trying to access the HTTP server through HTTPS proxy still, the traffic is not encrypted.

Upvotes: 1

Related Questions