Node.js中的肥皂请求,带有两个证券:TLS和WSS
我正在尝试创建SOAP客户端并将请求发送到外部服务器。这是代码:
const options = {
endpoint: endpoint,
pfx: fs.readFileSync(
"[cert-tls.p12]"
),
passphrase: "[password]",
};
soap.createClient(url, options, function (err, client) {
if (err) {
console.log("Error Occurred!!");
console.log(err);
} else {
var WssSecurity = new soap.WSSecurityCert(
fs.readFileSync(
"[privateKey.pem]"
),
fs.readFileSync(
"[publickey.pem]"
),
"[password]"
);
client.setSecurity(WssSecurity);
client.ObslugaRecepty.ObslugaReceptyWS.zapisPakietuRecept(
recepta_podpisana,
function (err, result) {
if (err) {
console.log("Error Occurred!!");
console.log(err);
}
}
);
}
});
我需要添加两个不同的证券以要求:SSL安全性和WS安全性。 如果我要运行我在这里提供的代码,我会遇到错误:
Error: write EPROTO 6512:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1546:SSL alert number 40
因此,第一件事是,我的客户不应用选项中的PFX CERT。要解决这个问题,我需要在soap.createclient(){}中添加它:
var tlsSecurity = new soap.ClientSSLSecurityPFX(
fs.readFileSync(
"[cert-tls.p12]"
),
"[password]"
);
client.setSecurity(tlsSecurity);
在添加client.setsecurity(tlssecurity)之前看到这些值
transitional: [Object],
pfx: <Buffer 30 82 18 51 02 01 03 30 82 18 0b 06 09 2a 86 48 86 f7 0d 01 07 01 a0 82 17 fc 04 82 17 f8 30 82 17 f4 30 82 05 b9 06 09 2a 86 48 86 f7 0d 01 07 01 a0 ... 6179 more bytes>,
passphrase: '[password]'
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
我 WSSECURITY和新错误是:
Error: wsse:InvalidSecurity: Missing wsse:Security header in request
是否有可能使用client.setsecurity();有两个不同的证书? 或不使用客户端的情况下正确提供TLS证书。Setsecurity(TLSSECURITY)还是对WSSECURITY做某事? 你有什么想法吗?
I am trying to create SOAP client and send a request to external server. This is the code:
const options = {
endpoint: endpoint,
pfx: fs.readFileSync(
"[cert-tls.p12]"
),
passphrase: "[password]",
};
soap.createClient(url, options, function (err, client) {
if (err) {
console.log("Error Occurred!!");
console.log(err);
} else {
var WssSecurity = new soap.WSSecurityCert(
fs.readFileSync(
"[privateKey.pem]"
),
fs.readFileSync(
"[publickey.pem]"
),
"[password]"
);
client.setSecurity(WssSecurity);
client.ObslugaRecepty.ObslugaReceptyWS.zapisPakietuRecept(
recepta_podpisana,
function (err, result) {
if (err) {
console.log("Error Occurred!!");
console.log(err);
}
}
);
}
});
I need to add two different securities to request: SSL Security and WS Security.
If I will run the code which i provide here, I am getting error:
Error: write EPROTO 6512:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1546:SSL alert number 40
So the first thing is, my client doesn't apply pfx cert which is in options. To get rid of this problem I need to add this inside the soap.createClient(){}:
var tlsSecurity = new soap.ClientSSLSecurityPFX(
fs.readFileSync(
"[cert-tls.p12]"
),
"[password]"
);
client.setSecurity(tlsSecurity);
And I see these values in response error message which wasn't there before adding client.setSecurity(tlsSecurity):
transitional: [Object],
pfx: <Buffer 30 82 18 51 02 01 03 30 82 18 0b 06 09 2a 86 48 86 f7 0d 01 07 01 a0 82 17 fc 04 82 17 f8 30 82 17 f4 30 82 05 b9 06 09 2a 86 48 86 f7 0d 01 07 01 a0 ... 6179 more bytes>,
passphrase: '[password]'
},
request: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
But this function is overwriting my WsSecurity and the new error is:
Error: wsse:InvalidSecurity: Missing wsse:Security header in request
Is there any possibility to use client.setSecurity(); with two different certificates?
Or provide tls certificate correctly without using client.setSecurity(tlsSecurity) or do something with WsSecurity?
Do you have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决问题的解决方案。这是一个带有类的安全性
。
I found a solution for my problem. Here is a security.js file with class which can stack different types of security:
and the usage in soap.createClient():