MB.*_*MB. 15 javascript ssl certificate
有没有办法检查JavaScript,如果给予主机它的SSL证书是有效的?(非阻塞)
在我的情况下,我想显示:"你也可以使用https:// .."如果通过JavaScript,我可以发出请求,https://my_url而不会被要求接受不受信任的证书.
这可以异步完成吗?
看看这里:https://support.mozilla.org/pl/questions/923494
<img src="https://the_site/the_image" onerror="redirectToCertPage()">
Run Code Online (Sandbox Code Playgroud)
但是,这可能是特定于Mozilla的.
无论如何,我会看看这些方面的解决方案是否有效:
<script> var sslCertTrusted = false; </script>
<script src="https://example.com/ssltest.js"></script>
<script>
if (!sslCertTrusted)
{
alert('Sorry, you need to install the certificate first.');
window.location('http://example.com/cert_install_instructions/');
}
else
{
// alert('Redirecting to secure connection')
window.location('https://example.com/');
}
<script>
Run Code Online (Sandbox Code Playgroud)
您当然需要让您的Web服务器在URL下返回此代码https://example.com/ssltest.js:
sslCertTrusted = true;
Run Code Online (Sandbox Code Playgroud)
我不确定细节.但我已经看到类似的技术用于检测广告拦截等.window如果变量不能被另一个脚本修改,你可能需要搭载在对象上,但通常使上述概念证明工作留作练习读者.
小智 5
我到目前为止所发现的 - 有可能使用Firefox,还不知道其他浏览器:
https://developer.mozilla.org/En/How_to_check_the_security_state_of_an_XMLHTTPRequest_over_SSL
这个问题没有意义。如果不打开与服务器的 SSL 连接,则无法获取服务器的 SSL 证书,一旦完成此操作,告诉用户他们也可以这样做就有点毫无意义了。
| 归档时间: |
|
| 查看次数: |
25719 次 |
| 最近记录: |