我试图在点击 ASP 页面后获取 HTML 响应。它具有 NTLM 身份验证,我尝试使用 npm-ntlm 客户端来解决该问题。响应是从 REST 客户端返回的,例如启用了 NTLM 的 postman (身份验证 header )。但是,在尝试从 npm-ntlm 请求相同的 URL 时在 JS 中,我收到错误:
SELF_SIGNED_CERT_IN_CHAIN
示例代码:
var options = {
method: 'GET',
username: "user",
password: "password@#",
uri: 'https://URL.com',
rejectUnauthorized: false,
agent: false
};
ntlm_req.request(options).then((res)=>{
console.log("success");
}, (err)=>{
console.log("err");
});
注意:我几乎尝试了其他答案中列出的所有方法来获取响应,但无法获取。
最佳答案
您应该尝试告诉request您的 ntlm 的实例调用忽略 ssl 问题。
试试这个:
var options = {
method: 'GET',
username: "user",
password: "password@#",
uri: 'https://URL.com',
request: {
rejectUnauthorized: false
// or this:
// strictSSL : false
},
agent: false
};
ntlm_req.request(options).then((res)=>{
console.log("success");
}, (err)=>{
console.log("err");
});
在我看来,你几乎做对了:)
您只是忘记正确传递请求的实例选项;)
关于javascript - GET 请求适用于浏览器的 REST 客户端,但不适用于 JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54254738/