GET 请求适用于浏览器的 REST 客户端,但不适用于 JS
GET Request works with Browser's REST Client but not with JS
我试图在点击 ASP 页面后获得 HTML 响应。它具有我尝试使用 npm-ntlm 客户端解决的 NTLM 身份验证。响应是从 REST 客户端返回的,例如启用了 NTLM 的邮递员 (Auth headers)。但是,在尝试从 JS 中的 npm-ntlm 请求相同的 URL 时,我收到错误消息:
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 instance of your 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");
});
在我看来,你几乎做对了:)
您只是忘记正确传递请求的实例选项 ;)
它通过以下列方式提供参数来与 httpntlm 一起工作:
httpntlm.get({
url: url, // complete URL to be fetched
username: 'user',
password: 'pswd',
workstation: 'MachineSerialNo', // host name
domain: ''
}
我试图在点击 ASP 页面后获得 HTML 响应。它具有我尝试使用 npm-ntlm 客户端解决的 NTLM 身份验证。响应是从 REST 客户端返回的,例如启用了 NTLM 的邮递员 (Auth headers)。但是,在尝试从 JS 中的 npm-ntlm 请求相同的 URL 时,我收到错误消息:
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 instance of your 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");
});
在我看来,你几乎做对了:)
您只是忘记正确传递请求的实例选项 ;)
它通过以下列方式提供参数来与 httpntlm 一起工作:
httpntlm.get({
url: url, // complete URL to be fetched
username: 'user',
password: 'pswd',
workstation: 'MachineSerialNo', // host name
domain: ''
}