【问题标题】:Rest API from nodejs to https url with port 8443 throwing error从nodejs到https url的Rest API,端口8443抛出错误
【发布时间】:2014-04-24 04:32:54
【问题描述】:

我正在尝试使用 http/https 模块从 nodejs 向 tomcat 服务器进行 API 调用

api url 有两种选择

  1. http://samleapiurl.com/getdata - 这工作正常,我得到响应

    var options = {
        host: 'samleapiurl.com',
        port: 80,
        path: '/getdata'
    };
    
    http.get(options, function(resp) {
        var body = '';
    
        resp.on('data', function(chunk) {
            body += chunk;
        });
        resp.on('end', function() {
            res.end(body);
        });
    }).on('error', function(e) {
        console.log("Got error: " + e.message);
    });
    
  2. https://samleapiurl.com:8443/getdata

    var options = {
        host: 'samleapiurl.com',
        port: 8443,
        path: '/getdata'
    };
    
    https.get(options, function(resp) {
        var body = '';
    
        resp.on('data', function(chunk) {
            body += chunk;
        });
        resp.on('end', function() {
            res.end(body);
        });
    }).on('error', function(e) {
        console.log("Got error: " + e.message);
    });
    

第二个选项不起作用,它会引发类似的错误

Got error: 10232:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert
internal error:openssl\ssl\s23_clnt.c:741:

如果尝试在 https 模式下访问 8443,我不确定为什么会收到此错误。 有没有人遇到过类似的问题?

【问题讨论】:

    标签: node.js api tomcat npm


    【解决方案1】:

    您可以尝试限制 tomcat 可以使用的密码,如 this blog 中所述,建议将以下行添加到 server.xml 的 SSL 连接器部分:

    ciphers="SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"
    

    【讨论】:

      猜你喜欢
      • 2013-07-01
      • 1970-01-01
      • 2019-05-21
      • 2021-06-21
      • 1970-01-01
      • 1970-01-01
      • 2019-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多