我正在尝试使用 http/https 模块从 nodejs 调用 API 到 tomcat 服务器
我有两个 api url 选项
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); });
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,我不确定为什么会出现此错误。 有没有人遇到过类似的问题?
最佳答案
您可以尝试限制 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"
关于node.js - 从 nodejs 到 https url 的 Rest API,端口 8443 抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23254238/