节点肥皂 ClientSSLSecurityPFX - 403 Forbidden
Node soap ClientSSLSecurityPFX - 403 Forbidden
我正在尝试使用 node-soap 连接到 SOAP 服务,但得到的是 403 - Forbidden
。
我有一个 pfx 文件和一个密码,我正在尝试:
var pfx = fs.readFileSync(path.join(__dirname, 'folder', 'my.pfx')); // pfx file is in the relative path './folder/my.pfx'
var password = 'mypassword';
var options = {
strictSSL: true,
rejectUnauthorized: false,
hostname: myUrl,
forever: true
};
var security = new soap.ClientSSLSecurityPFX(pfx, password, options);
var url = 'https://theservice.com/ApplicationService.svc?singleWsdl';
soap.createClient(url, function (err, client) {
console.log(err);
console.log(client);
client.setSecurity(security);
});
但是我得到 403:
[Error: Invalid WSDL URL: https://theservice.com/ApplicationService.svc?singleWsdl
Code: 403
Response Body: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>403 - Forbidden: Access is denied.</title>...
client.setSecurity(security);
^
TypeError: Cannot read property 'setSecurity' of undefined
通过将 pfx 安装到 MacOS Keychain,我可以通过浏览器访问该服务。所以URL,pfx,password等应该没问题。
关于可能是什么问题以及如何调试的任何想法?谢谢!
我通过将 pfx 和密码设置为 options.wsdl_options
:
成功连接
var options = {
wsdl_options: {
forever: true,
rejectUnauthorized: false,
strictSSL: false,
pfx: fs.readFileSync(__dirname + '/folder/my.pfx'),
passphrase: 'myPass'
}
};
soap.createClient(myUrl, options, function (err, client) {
console.log(err);
console.log(client);
});
通过这种方式,他们最终获得 HTTP 选项并启用与客户端证书的连接。
在我的例子中,除了@mooses 的回答之外,我还必须这样做,也许它会对某人有所帮助(使用他们的示例):
var options = {
wsdl_options: {
forever: true,
rejectUnauthorized: false,
strictSSL: false,
pfx: fs.readFileSync(__dirname + '/folder/my.pfx'),
passphrase: 'myPass'
}
};
soap.createClient(myUrl, options, function (err, client) {
client.setSecurity(new soap.ClientSSLSecurityPFX(pfx, pfxPass)); // <-----
console.log(err);
console.log(client);
});
我正在尝试使用 node-soap 连接到 SOAP 服务,但得到的是 403 - Forbidden
。
我有一个 pfx 文件和一个密码,我正在尝试:
var pfx = fs.readFileSync(path.join(__dirname, 'folder', 'my.pfx')); // pfx file is in the relative path './folder/my.pfx'
var password = 'mypassword';
var options = {
strictSSL: true,
rejectUnauthorized: false,
hostname: myUrl,
forever: true
};
var security = new soap.ClientSSLSecurityPFX(pfx, password, options);
var url = 'https://theservice.com/ApplicationService.svc?singleWsdl';
soap.createClient(url, function (err, client) {
console.log(err);
console.log(client);
client.setSecurity(security);
});
但是我得到 403:
[Error: Invalid WSDL URL: https://theservice.com/ApplicationService.svc?singleWsdl
Code: 403
Response Body: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>403 - Forbidden: Access is denied.</title>...
client.setSecurity(security);
^
TypeError: Cannot read property 'setSecurity' of undefined
通过将 pfx 安装到 MacOS Keychain,我可以通过浏览器访问该服务。所以URL,pfx,password等应该没问题。
关于可能是什么问题以及如何调试的任何想法?谢谢!
我通过将 pfx 和密码设置为 options.wsdl_options
:
var options = {
wsdl_options: {
forever: true,
rejectUnauthorized: false,
strictSSL: false,
pfx: fs.readFileSync(__dirname + '/folder/my.pfx'),
passphrase: 'myPass'
}
};
soap.createClient(myUrl, options, function (err, client) {
console.log(err);
console.log(client);
});
通过这种方式,他们最终获得 HTTP 选项并启用与客户端证书的连接。
在我的例子中,除了@mooses 的回答之外,我还必须这样做,也许它会对某人有所帮助(使用他们的示例):
var options = {
wsdl_options: {
forever: true,
rejectUnauthorized: false,
strictSSL: false,
pfx: fs.readFileSync(__dirname + '/folder/my.pfx'),
passphrase: 'myPass'
}
};
soap.createClient(myUrl, options, function (err, client) {
client.setSecurity(new soap.ClientSSLSecurityPFX(pfx, pfxPass)); // <-----
console.log(err);
console.log(client);
});