问题描述
是否有一种JavaScript在浏览器中运行的方法,以确定哪个CA证书用于为浏览器的当前HTTPS连接验证远程主机,还获取该证书的属性,例如CA的名称?
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?
如果没有,是否有任何其他选项以编程方式获取此信息,例如服务器端的ActiveX,Java,CGI,......?
If not, are there any other options for programatically obtaining this information, such as ActiveX, Java, CGI on the server side, ...?
推荐答案
您可以使用开源这样做。它在JavaScript中实现SSL / TLS。您可以对服务器进行ajax调用,并使用回调来检查证书。请记住,服务器是发送JavaScript的服务器,因此不应该用它来确定您是否信任JavaScript来自的服务器。 Forge项目允许跨域请求,因此如果您使用它来进行信任,则可以从您已信任的服务器加载Forge JavaScript,然后联系您不信任的服务器。但是,除非该其他服务器提供跨域策略,否则您将无法执行跨域请求。
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.
自述文件中的博客链接提供了有关如何使用Forge及其工作原理的更多信息。
The blog links in the README provide more information on how Forge can be used and how it works.
这篇关于在Web浏览器中,JavaScript是否可以获取有关当前页面使用的HTTPS证书的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!