我有一个PFX文件。我生成了PEM和KEY文件:
openssl pkcs12 -in cert.pfx -out cert.pem -clcerts -nokeys
openssl pkcs12 -in cert.pfx -out cert.key -nocerts -nodes
My Node.js配置文件如下所示:
var soap = require('soap'),
fs = require('fs');
var url = 'https://file.wsdl';
var auth = "Basic " + new Buffer("username" + ":" + "password").toString("base64");
soap.createClient( url, {wsdl_options: {
cert: fs.readFileSync('cert/cert.pem'),
key: fs.readFileSync('cert/cert.key'),
strictSSL: false,
rejectUnauthorized: false
}, wsdl_headers: {Authorization: auth}, endpoint : 'https://linkToPostHttpsRequest'}, function(err, client) {
if(err) {throw err;}
client.admGetSubscriber({input: {msisdn: asdasd}}, function(err, result){
throw err;
console.log(result);
});
Node.js告诉我这个错误:
Error: write EPROTO 101057795:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake
failure:openssl\ssl\s3_pkt.c:1472:SSL alert number 40
101057795:error:1409E0E5:SSL routines:ssl3_write_bytes:ssl handshake failure:openssl\ssl\s3_pkt.c:656:
at exports._errnoException (util.js:1007:11)
at WriteWrap.afterWrite (net.js:793:14)
我尝试导入PFX证书但收到同样的错误。我还应该包括其他选项吗?
答案 0 :(得分:0)
尝试添加请求选项'ciphers':'ALL'。
代码:
var soap = require('soap'),
request = require('request'),
fs = require('fs');
var url = 'https://file.wsdl';
var auth = "Basic " + new Buffer("username" + ":" + "password").toString("base64");
var request_with_defaults = request.defaults({ 'ciphers': 'ALL' });
soap.createClient(url, {
request: request_with_defaults,
wsdl_options: {
cert: fs.readFileSync('cert/cert.pem'),
key: fs.readFileSync('cert/cert.key'),
strictSSL: false,
rejectUnauthorized: false
}, wsdl_headers: { Authorization: auth }, endpoint: 'https://linkToPostHttpsRequest'
}, function (err, client) {
if (err) { throw err; }
client.admGetSubscriber({ input: { msisdn: asdasd } }, function (err, result) {
throw err;
console.log(result);
});
});