How does my browser convert my HTTP request to https?

Friends I want to know when secure hosting is done, we need a unique ip address in order to associate our SSL certificate with it. In addition, I once read in one tutorial that when a browser requests a secure connection, all SSL processes are initiated. But how does the browser request a secure connection. Don't we just write www.chase.com? And then our browser will convert http to https? What happens in the background?

+4
source share
2 answers

Step by step:

  • Client type www.example.com in the address bar
  • The browser accepts the HTTP protocol and sends a GET call to www.example.com
  • www.example.com responds with the moved status code and gives a new location:

    HTTP / 1.1 301 moved forever | Location: https : //www.example.com/

  • The browser reads this and knows that it must start a secure HTTP connection.

  • ... and so on. Here the situation is complicated, as the browser and server exchange several messages until a secure connection is established.

In any case, if you need to install an SSL certificate, you must ensure that your client is redirected from HTTP to HTTPS. This should be done from server configurations.

+10
source

In your program code, you evaluate the protocol and redirect using 301 (server-side). This is not done in the browser .

You can do this in ASP.NET in the Global.asax file
I am not sure about other programming languages ​​(PHP, Ruby, etc.). Others are free to call and edit their answer with more examples if they wish.

 if(!Request.IsSecureConnection) { string redirectUrl = Request.Url.ToString().Replace("http:", "https:"); HttpContext.Current.Response.Status = "301 Moved Permanently"; HttpContext.Current.Response.AddHeader("Location", redirectUrl); } 

I think you can do this by default in Apache using .htaccess, but as far as I can tell, if you want to do this in IIS you need to run asp script or include it in your .net application, I could be wrong, but this is what I encountered in my trials.

+3
source

All Articles