Nodejs-soap, how to use SSL and usernameToken

1.784 visualizações
Pular para a primeira mensagem não lida

Miha Zoubek

não lida,
16 de set. de 2016, 15:25:3616/09/2016
para nodejs
Hi

I am trying to use library nodejs-soap (https://github.com/vpulim/node-soap) but do not know how to use SSL and usernameToken auth.

So my code goes like this: 

var url = 'https://test.wsdl'; var auth = "Basic " + new Buffer("test" + ":" + "test").toString("base64"); var token = wsse({ username: 'test', password: 'test' }); soap.createClient( url, {wsdl_options: { cert: fs.readFileSync('cert/test.pem'), key: fs.readFileSync('cert/test.key'), strictSSL: false, rejectUnauthorized: false, secureOptions : require('constants').SSL_OP_NO_TLSv1_2 }, endpoint : 'https://test.com'}, function(err, client) { if(err) {throw err;} /* client.setSecurity(new soap.ClientSSLSecurity( 'cert/test.key' , 'cert/test.pem' , { strictSSL: false, rejectUnauthorized: false, secureOptions : require('constants').SSL_OP_NO_TLSv1_2 } )); */ console.log(client.describe() ); client.admGetSubscriber({input: {msisdn: 123213}}, {wsdl_headers: { Username: 'test', Password: token.getPasswordDigest() }}, function(err, result){ if (err) throw err; //throw err; }); });


When I use soap.createClient(), in callbackI can see that wdsl is recived from url, so to this point SSL works (no need for usernameToken auth). Then when I try to use client and call some function I must define again SSL certificate,
client.setSecurity(new soap.ClientSSLSecurity()) otherwise I will get SSL error (again?). In post I must also define usernameToken auth otherwise server will reject request. The issue is that I can not define client.setSecurity two times as only the last will be used.


tnx for all help!
miha
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem