Meteor.http.get请求 - >错误:主机名/ IP与证书的altnames不匹配

时间:2013-12-10 15:50:02

标签: javascript http meteor

我正在尝试使用meteor.http模块,我在服务器端遇到以下错误。 “错误:主机名/ IP与证书的altnames不匹配”因为我是Meteor和Node.js中的新手并且其javaScript调试很难(顺便说一下我如何调试服务器端脚本?客户端很容易),我是使用MAC OS X 10.9不确定它是否相关......

由于 RONEN

客户端代码:

'click #buildButton' : function () {
  console.log("Jenkins job request");
  $('#buildButton').attr('disabled','true').val('loading...');
  var userName = "Ronen";
  Meteor.call('jenkinsServiceBuild', function(err, respJson) {
    if(err) {
      window.alert("Error: " + err.reason);
      console.log("error occured on receiving data on server. ", err );
    } else {
      window.alert("Success: ");
      console.log("respJson: ", respJson);
      //window.alert(respJson.length + ' tweets received.');
      Session.set("recentTweets",respJson);
    }
    $('#buildButton').removeAttr('disabled').val('build');
  });
}

服务器端代码:

Meteor.methods({jenkinsServiceBuild: function(userName) {
  var url = "https://www.ynet.co.il";
  //synchronous GET
  var result = Meteor.http.get(url, {timeout:30000});
  if(result.statusCode==200) {
    var respJson = JSON.parse(result.content);
    console.log("response received.");
    return respJson;
  } else {
    console.log("Response issue: ", result.statusCode);
    var errorJson = JSON.parse(result.content);
    throw new Meteor.Error(result.statusCode, errorJson.error);
  }
}

});

1 个答案:

答案 0 :(得分:0)

网站“https://www.ynet.co.il”未正确安装该域的SSL证书。它使用的是akamai的证书。

如果您知道并信任该网站,并且没有太安全,只需删除https中的s

即可
var url = "http://www.ynet.co.il";

此外,我不确定代码是否有效,查看它提供html内容的网站,但这一行:

var respJson = JSON.parse(result.content);

建议它提供JSON内容。如果它确实服务器json内容使用此代替:

var respJson = result.data;