Tag: https

调试时,Visual Studio网站将http重定向到https

我遇到IIS Express或Visual Studio 2013的问题。 该站点在属性中没有启用或设置https或ssl。 当我单击调试时,该站点将在http://localhost:61488/Default.aspx启动并尝试加载: http://localhost:61488/Default.aspx 然后由于某种原因自动重定向到: https://localhost:61488/Default.aspx然后我得到一个Error code: ERR_SSL_PROTOCOL_ERROR中的Error code: ERR_SSL_PROTOCOL_ERROR 我不太清楚该怎么办?

在C#中使用https的HttpWebRequest

这段代码不起作用; 它正在登录使用https协议的网站。 如何解决这个问题呢? 代码在GetRequestStream()随时随地停止,表示协议违规exception未处理。 string username = “user”; string password = “pass”; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(“https://moje.azet.sk/prihlasenie.phtml?KDE=www.azet.sk%2Findex.phtml%3F”); request.UserAgent = “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)”; Console.WriteLine(request.GetRequestStream()); using (StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII)) { writer.Write(“nick=” + username + “&password=” + password); } HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //Retrieve your cookie that id’s your […]

C# – 连接:在HttpWebRequest期间未发送保持活动标头

我正在尝试发送以使用我的HttpWebRequest发送以下标头: Connection: keep-alive 但是,标头永远不会发送。 Fiddler2显示,每当我在Google Chrome中请求该页面时,都会发送标题。 但是,我的应用程序由于某种原因拒绝发送此标头。 我已将KeepAlive属性设置为true (默认情况下默认为true ),但标题仍未发送。 我正在尝试使用多个HttpWebRequests发送此标头,但它们基本上都是这样的: HttpWebRequest logIn6 = (HttpWebRequest)WebRequest.Create(new Uri(responseFromLogIn5)); logIn6.CookieContainer = cookies; logIn6.KeepAlive = true; logIn6.Referer = “https://login.yahoo.com/config/login?.src=spt&.intl=us&.lang=en-US&.done=http://football.fantasysports.yahoo.com/”; logIn6.UserAgent = “Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1”; logIn6.Accept = “text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”; logIn6.Headers.Add(“Accept-Encoding:gzip,deflate,sdch”); logIn6.Headers.Add(“Accept-Language:en-US,en;q=0.8”); logIn6.Headers.Add(“Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3”); logIn6.AllowAutoRedirect = false; HttpWebResponse logIn6Response = (HttpWebResponse)logIn6.GetResponse(); string responseFromLogIn6 = logIn6Response.GetResponseHeader(“Location”); […]

WCF,HTTPS与HTTP

有两个样本 对于HTTP : using System; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Security; namespace ConsoleApplication1 { internal class Program { private static void Main(string[] args) { string addressHttps = String.Format(“http://{0}:51222”, Dns.GetHostEntry(“”).HostName); var wsHttpBinding = new BasicHttpBinding(); var serviceHost = new ServiceHost(typeof (HelloWorldService), new Uri(addressHttps)); Type endpoint = typeof (IHelloWorldService); serviceHost.AddServiceEndpoint(endpoint, wsHttpBinding, […]

当前请求是通过使用Azure部署的SSL进行的

context.Request.IsSecureConnection 即使通过HTTPS提供连接,始终在Azure部署中返回false。 在查看为Azure部署的站点发送的标头后,我发现: X-Forwarded-Proto=https 此标头是否保证与网站的客户端连接在HTTPS下,与context.Request.IsSecureConnection连接方式相同?

是什么让这个HTTPS WebRequest即使在浏览器中运行也会超时?

这是我的要求: var request = (HttpWebRequest) WebRequest.Create(“https://mtgox.com/”); request.CookieContainer = new CookieContainer(); request.AllowAutoRedirect = false; request.Accept = “text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”; request.Headers[HttpRequestHeader.AcceptEncoding] = “gzip, deflate”; request.Headers[HttpRequestHeader.AcceptLanguage] = “en-gb,en;q=0.5”; request.Headers[HttpRequestHeader.AcceptCharset] = “ISO-8859-1,utf-8;q=0.7,*;q=0.7”; request.Timeout = 5000; request.UserAgent = “Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0”; request.Method = “GET”; request.GetResponse(); 使用HttpFox从Firefox复制标题。 我使用Fiddler2来validation至少对于HTTP请求,标头在Firefox请求和我的请求之间是完全相同的。 但是,当使用HTTPS 对此特定网站执行请求时,请求会超时。 它适用于其他网站。 我必须以与Firefox不同的方式执行它,因为它始终适用于Firefox。 但是,我无法使用Fiddler2调试它,因为每当Fiddler2转发这些请求时,它们也会超时 ,即使是由Firefox发起的。 它只是一个非常错误的网站吗? 上面的哪一部分让我离开了不是Firefox?

调试失败的HTTPS WebRequest

我正在编写一个小程序,它将使用HTTPS和HttpWebRequest类向服务器发出GET请求。 服务器(显然)有一个服务器证书。 它还希望客户提供证书。 但是,在发出请求时,我收到一个System.Net.WebException,指出无法建立安全的TLS / SSL连接。 我很快发现服务器的证书无效。 假设这是造成exception的原因,我试图接受无效证书(遗憾的是,更新证书不是一个选项),使用下面的代码: ServicePointManager.ServerCertificateValidationCallback += delegate { return true; }; 然而,这并没有解决问题。 由于exception没有给出任何细节,因此很难确定导致它的原因。 我尝试覆盖无效的服务器证书是否无效? 我提供的客户端证书是否不受服务器信任? 我没有以正确的方式加载客户端证书吗? 我喜欢有关如何调试此类问题的提示。 遗憾的是,我无法访问服务器或其日志。 以下是代码的重要部分: ServicePointManager.ServerCertificateValidationCallback += delegate { return true; }; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); // url is an HTTPS URL. X509Certificate clientCert = new X509Certificate(“certificate.crt”, “password”); req.ClientCertificates.Add(clientCert); WebResponse resp = req.GetResponse(); // This fails!

从WebClient获取HTTP 302重定向的位置?

我有一个返回HTTP 302重定向的URL,我想获取它重定向到的URL。 问题是System.Net.WebClient似乎实际上遵循它,这很糟糕。 HttpWebRequest似乎也是如此。 有没有办法制作一个简单的HTTP请求并返回目标位置而不使用WebClient? 我很想做原始套接字通信,因为HTTP很简单,但网站使用HTTPS,我不想做握手。 最后,我不关心我使用哪个类,我只是不希望它遵循HTTP 302重定向:)

如何在Webbrowser控件中禁用“安全警报”窗口

我正在使用Webbrowser控件使用“不受信任的证书”登录HTTPS站点。 但我得到一个关于不受信任的证书的弹出窗口“安全警报”: 我必须按标题找到这个窗口并发送Alt + Y按是 : int iHandle = NativeWin32.FindWindow(null, “Security Alert”); NativeWin32.SetForegroundWindow(iHandle); System.Windows.Forms.SendKeys.Send(“Y%”); 但用户可以看到此窗口的闪烁。 如何忽略此警报? 或者在Webbrowser控件中禁用此“不受信任的证书”检查?

使用c#Webclient通过https请求html

我正在通过c#WebClient类从我无法控制的站点尝试各种html资源。 当我尝试访问“ https://archive.org/details/OTRR_In_The_Name_Of_The_Law_Singles ”等url时 我收到错误:System.Net.WebException:请求已中止:无法创建SSL / TLS安全通道。 我找到的解决方案建议我使用以下代码忽略证书要求并使webclient充当浏览器,但我仍然收到相同的错误 ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate { return true; }); using(WebClient webClient = new WebClient()) { webClient.Headers[“User-Agent”] = “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)”; webClient.Headers[“Accept”] = “text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”; webClient.Headers[“Accept-Language”] = “en-us,en;q=0.5”; webClient.Headers[“Accept-Encoding”] = “gzip,deflate”; webClient.Headers[“Accept-Charset”] = “ISO-8859-1,utf-8;q=0.7,*;q=0.7”; StreamReader sr = new StreamReader(webClient.OpenRead(inputString)); […]