在 javascript 中检测 SNI(服务器名称指示)浏览器支持 [英] Detecting SNI (Server Name Indication) browser support in javascript

查看:34
本文介绍了在 javascript 中检测 SNI(服务器名称指示)浏览器支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够检测浏览器是否支持 SNI - 服务器名称指示.我希望将不合规的客户重定向到不同的地址.

I want to be able to detect if the browser support SNI - Server Name Indication. I'm hoping to redirect non compliant clients to a different address.

我正在考虑通过 SSL 加载一些内容并确保其安全传输.否则浏览器不支持 SNI.这可以做到吗?

I was thinking of loading some content through SSL and make sure it was transfered securely. Otherwise the browser doesn't support SNI. Can this be done?

推荐答案

你可以设置一个支持 SNI 的服务器,提供两个主机名,在你需要 SNI 的地方和一个作为后备解决方案的地方,两者都提供他们的名字正在托管.

You could set up a server that supports SNI, serving two host names, on where you require SNI and one that's a fallback solution, both serving the name that they are hosting.

类似的东西:

  • https://www.example.com/name 返回表示 I'm www.example.com
  • https://www.example.net/name 返回 I'm www.example.net(并且需要 SNI).
  • https://www.example.com/name returns a representation saying I'm www.example.com
  • https://www.example.net/name returns I'm www.example.net (and requires SNI).

如果您向 https://www.example.net/name 发出 XHR 请求并返回 www.example.com,则浏览器不会支持SNI.

If you make an XHR request to https://www.example.net/name and it returns www.example.com, then the browser doesn't support SNI.

这篇关于在 javascript 中检测 SNI(服务器名称指示)浏览器支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆