如何燮preSS SSL错误,当AJAX请求到服务器证书无效证书、错误、服务器、preSS

2023-09-11 22:30:48 作者:惊鸿客

我有这个code:

function newXMLHttpRequest() {
    var xmlHttp;
    try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (f) {
            xmlHttp = new XMLHttpRequest();
        }
    }
    return xmlHttp;
}
var xmlHttp = newXMLHttpRequest();
xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = function() {
    // this I have xmlHttp.status = 12019        
    alert("readyState = " + xmlHttp.readyState + "\nstatus = " + xmlHttp.status);
}
xmlHttp.send('same data');

当我发送请求到服务器证书无效,我有一个状态code 12019的错误。

When I send request to the server with invalid certificate I have error with status code 12019.

解决方案应该是跨浏览器(IE,FF,铬)

Solution should be cross-browser (IE, FF, Chrome)

推荐答案

首先,要回答标题中的问题,这不能这样做。客户端XMLHTTP库不允许客户端忽略SSL错误。该 MsXml2.ServerXMLHTTP 的对象确实允许一个无视与的SetOption(2,13056)的方法。然而,该对象不能被一个浏览器中使用时,也不是跨平台的

First, to answer the question in the title, this cannot be done. The client xmlHttp libraries do not allow the client to ignore ssl errors. The MsXml2.ServerXMLHTTP object does allow one to ignore SSL errors with the setOption(2, 13056) method. However, this object cannot be used within a browser, nor is it cross-platform.

不过,似乎有另外一个问题。在12019状态并未指示无效的认证。一些变异的HTTP 403状态code,或许多的无效的认证'codeS可以预期在这种情况下。

That said, there seems to be another issue. The 12019 status does not indicate an invalid certification. Some variant of an HTTP 403 status code, or one of the many 'invalid certification' codes would be expected in that case.

您 12019状态code 表示:

ERROR_INTERNET_INCORRECT_HANDLE_STATE

12019

所请求的操作,不能进行,因为供给的手柄未处于正确的状态。

The requested operation cannot be carried out because the handle supplied is not in the correct state.

不幸的是这个状态code没有真正的沟通多了,不知道什么是IE浏览器的版本,和详细信息的服务器有没有更多的去。我检查了一些论坛帖子。 一说切换到IIS固定的问题,的另一个的说,临时文件无法被覆盖导致的问题。大多数职位然而,没有一个满意的,还是决定性的结论。

Unfortunately this status code doesn't really communicate much, and without knowing what versions of IE, and details about the server there's not much more to go on. I've checked a number of forum posts. One stated switching to IIS fixed the issue, another stated that temporary files that could not be overwritten lead to the problem. Most posts however, do not have a satisfactory, or decisive conclusion.