【发布时间】:2014-04-24 04:32:54
【问题描述】:
我正在尝试使用 http/https 模块从 nodejs 向 tomcat 服务器进行 API 调用
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,我不确定为什么会收到此错误。 有没有人遇到过类似的问题?
【问题讨论】: