I try to use HTTPS, but I constantly receive 407 errors in response. Certificate is installed

Posted almost 6 years ago by jeronimo

Post a topic
Un Answered
j
jeronimo

 I try to use HTTPS, but I constantly receive 407 errors in response. Certificate is installed


 var myProxy = new WebProxy("http://proxy.crawlera.com:8010");

 string apiKey = "<apiKey>:"; // Note the ":" sign at the end

            var encodedApiKey = Base64Encode(apiKey);


            var request = (HttpWebRequest)WebRequest.Create("https://httpbin.org/ip");

            request.Headers.Add("Proxy-Authorization", "Basic " + encodedApiKey);

 request.Proxy = myProxy;

            request.PreAuthenticate = true;

            request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;


            var response = request.GetResponse();

            Console.WriteLine("Response Status: " + ((HttpWebResponse)response).StatusDescription);

            Console.WriteLine("\nResponse Headers:\n" + ((HttpWebResponse)response).Headers);

            var dataStream = response.GetResponseStream();

            var reader = new StreamReader(dataStream);

            string responseFromServer = reader.ReadToEnd();

            Console.WriteLine("Response Body:\n" + responseFromServer);

 reader.Close();

 response.Close();

 }


        public static string Base64Encode(string apiKey)

 {

            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(apiKey);

            return System.Convert.ToBase64String(plainTextBytes);

 }

1 Votes


1 Comments

Adriana Anghel

Adriana Anghel posted almost 6 years ago Admin

Hi! I have converted this into a support ticket - you should have received an email notification. One of our Support Engineers will be in touch soon. Bear in mind that while you have an active subscription with us, you are able to open support tickets directly from your dashboard, under Help - Contact Support. We respond to support tickets within one business day. The forum is for customers who don't have an active subscription with us.

0 Votes

Login to post a comment