node.js - SOAP 请求和 "SSL routines:ssl3_read_bytes:sslv3 alert handshake failure"

标签 node.js ssl openssl soap-client

我有一个 PFX 文件。我生成了 PEM 和 KEY 文件:

  • openssl pkcs12 -in cert.pfx -out cert.pem -clcerts -nokeys
  • openssl pkcs12 -in cert.pfx -out cert.key -nocerts -nodes

我的 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 show me 抛出这个错误:

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 证书,但遇到同样的错误。还有其他我应该包括的选项吗?

最佳答案

尝试添加请求选项 '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);
    });
});

关于node.js - SOAP 请求和 "SSL routines:ssl3_read_bytes:sslv3 alert handshake failure",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39146719/

相关文章:

javascript - 如何通过命令行在 Windows 上卸载 node-gyp

node.js - Nodejs为Redis请求设置超时

Ruby:使用存储在 TPM 中的 key

c# - 通过 SSL 保护 Xamarin.Forms 应用程序流量

java - 如何在java中使用私钥(.private)解密数据

linux - 努力更新到最新的 openssl 版本

node.js - nodejs neo4j 不访问参数 req.params.x 但接受任何硬编码值

javascript - 如何编写返回异步的 API 调用的简单模拟

python-3.x - 在 python/flask 中使用 .der 证书

php - 如何创建新的 key 对并将它们保存在文件中?