在 Web 浏览器中,JavaScript 是否可以获取有关当前页面使用的 HTTPS 证书的信息? [英] Within a web browser, is it possible for JavaScript to obtain information about the HTTPS Certificate being used for the current page?

查看:36
本文介绍了在 Web 浏览器中,JavaScript 是否可以获取有关当前页面使用的 HTTPS 证书的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Is there a method for JavaScript running in a browser to determine which CA certificate is being used to authenticate the remote host for the browser's current HTTPS connection, and also obtain properties of that certificate, such as the name of the CA?

If not, are there any other options for programatically obtaining this information, such as ActiveX, Java, CGI on the server side, ...?

解决方案

You can use the opensource Forge project to do this. It implements SSL/TLS in JavaScript. You can make an ajax call to the server and use a callback to inspect the certificate. Keep in mind that the server is the one sending the JavaScript so this shouldn't be used to determine whether or not you trust the server the JavaScript is from. The Forge project does allow cross-domain requests, so if you are using this for trust, you can load the Forge JavaScript from a server you already trust and then contact the server you don't yet trust. However, unless that other server provides a cross-domain policy, you will not be able to perform the cross-domain request.

https://github.com/digitalbazaar/forge/blob/master/README.md

The blog links in the README provide more information on how Forge can be used and how it works.

这篇关于在 Web 浏览器中,JavaScript 是否可以获取有关当前页面使用的 HTTPS 证书的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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