Javascript XMLHttpRequest:忽略无效的SSL证书 [英] Javascript XMLHttpRequest: Ignore invalid SSL Certificate
问题描述
所以我一直无法从与https接口的设备中获取信息,因为它的安全证书无效。我知道该设备是值得信任的,我无法访问服务器端,所以我无法更改它。我想知道是否有任何方法可以在Javascript中设置XMLHttpRequest对象来忽略无效的SSL证书,并且无论如何都只是获取信息。因为它现在似乎只是拒绝证书并停止。谢谢。
so I have been having trouble with grabbing information from a device that is interfaced with via https due to the fact that it has an invalid security certificate. I know the device is to be trusted and I don't have access to the server-side so I can't change it. I was wondering if there was any way to set up an XMLHttpRequest object in Javascript to just ignore an invalid SSL certificate and just grab the information anyway. As it is now it seems to just reject the certificate and stop. Thanks.
推荐答案
我之前找到了这个解决方案,但它没有用,这是因为我还在使用实际的XMLHttpRequest虽然。使用以下语句创建时:
Well I had found this solution before but it didn't work, this was because I was still using actual XMLHttpRequest though. When creating it using this statement:
httpreq = new ActiveXObject("Msxml2.ServerXMLHTTP.3.0");
有一个名为setOption的方法可供使用:
There is a method called setOption that is opened up for use:
httpreq.setOption(2, 13056);
使用这些参数,请求现在忽略无效证书并获取信息。如果我理解正确,这将无法与任何试图运行脚本的非Microsoft技术一起使用,但这对我的项目范围是可行的。
With those parameters, the request now ignores the invalid certificate and grabs the information anyway. If I understand correctly this won't work with any non-Microsoft technology trying to run the script, but that's ok for the scope of my project.
这篇关于Javascript XMLHttpRequest:忽略无效的SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!