我的浏览器如何将我的 http 请求转换为 https?

发布于 2024-09-26 16:15:33 字数 159 浏览 3 评论 0原文

朋友们,我想知道当安全托管完成后,我们需要一个唯一的 IP 地址来将我们的 SSL 证书关联到它。另外,我在一篇教程中读到,当浏览器请求安全连接时,所有 SSL 进程都会启动。但是浏览器如何请求安全连接。我们不就写www.chase.com吗?然后我们的浏览器将http转换为https?后台发生了什么?

Friends I want to know for when a secured hosting is done, we require an unique ip address to associate our SSL Certificate to it. Also, I kinda read in one tutorial that when a browser requests for a secured conncetion then all the SSL process initiates. But how does a browser request for a secure connection. Don't we just write www.chase.com? And then our browser converts the http to https? Whats happening in the background?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌梦深 2024-10-03 16:15:33

一步一步(假设 HSTS 标头处于活动状态,它将自动使用 https,而无需创建https >http 请求):

  1. 客户端在地址栏中键入 www.example.com
  2. 浏览器采用 HTTP 协议并向 www.example.com 发送 GET 调用
  3. www.example .com 以移动后的状态代码进行响应并给出新位置:

    HTTP/1.1 301 永久移动
    位置:https://www.example.com/

  4. 浏览器读取该内容并知道它必须启动安全 HTTPS 连接。

  5. ...等等。这就是事情变得更加复杂的地方,因为浏览器和服务器交换多个消息,直到建立安全连接。

无论如何,如果您需要安装 SSL / TLS 证书,则必须确保您的客户端从 HTTP 重定向到 HTTPS。这应该通过服务器配置来完成。

Step by step (Assuming HSTS header is not active in which it will automatically use https without making a http request):

  1. The client types www.example.com in the address bar
  2. The browser assumes HTTP protocol and sends a GET call to www.example.com
  3. www.example.com responds with a moved status code and gives the new location:

    HTTP/1.1 301 Moved Permanently
    Location: https://www.example.com/

  4. The browser reads that and knows that it must start a Secure HTTPS connection.

  5. ...and so on. This is where things get more complicated because the browser and the server exchange multiple messages until the secure connection is established.

Anyway, if what you need is to install an SSL / TLS certificate you must make sure that your client is redirected from HTTP to HTTPS. That should be accomplished from the server configurations.

困倦 2024-10-03 16:15:33

在您的编程代码中,您可以使用 301(服务器端)评估协议并进行重定向。 这不是在浏览器中完成的

您可以在 ASP.NET 中的 Global.asax 文件中执行此操作
我不确定其他编程语言(PHP、Ruby 等)。其他人可以随意插话并用更多示例编辑我的答案。

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

我认为默认情况下您可以使用 .htaccess 在 Apache 中执行此操作,但据我所知,如果您想这样做在 IIS 中,您需要运行一个 asp 脚本或将其包含在您的 .net 应用程序中。我可能是错的,但这就是我在尝试中遇到的问题。

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

You can do this in ASP.NET in the Global.asax file
I'm not sure about other programming languages (PHP, Ruby, etc). Others can feel free to chime in and edit my answer with more examples if they please.

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 it in IIS you need to run an asp script or include it in your .net application. I could be wrong, but this is what I've come up against in my trials of this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文