使用grunt服务器运行SSL时出错

时间:2013-09-16 05:44:24

标签: ssl gruntjs yeoman

我正在研究基于yeoman的angular.js应用程序。

我们已将gruntfile设置为在https上运行。

它在我的同事机器上工作正常但不在我的机器上。

在Chrome中我得到:

SSL connection error. 
Unable to make a secure connection to the server. 
This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have.

在Firefox中我得到:

The connection was interrupted
The connection to localhost:9000 was interrupted while the page was loading.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer's network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

我已经仔细检查过我们安装了相同的npm模块。

gruntfile的相关部分是

connect: {
  options: {
    port: 9000,
    hostname: 'localhost',
    protocol: 'https',
    key: grunt.file.read('server.key').toString(),
    cert: grunt.file.read('server.crt').toString(),
    ca: grunt.file.read('ca.crt').toString(),
    passphrase: 'grunt',


  },
  livereload: {
    options: {
      protocol: 'https',
      middleware: function (connect) {
        return [
          modRewrite([
            '^/api/(.*) /api/index.php?$1 [L]',
            '!\\.html|\\.js|\\.php|\\.css|\\.png$ /index.html [L]'
          ]),
          lrSnippet,
          phpGateway('app'),

          mountFolder(connect, '.tmp'),
          mountFolder(connect, yeomanConfig.app)
        ];
      }
    }
  },

我的同事生成了证书文件,但这并不重要,因为我有这些文件的确切副本。

最奇怪的是,我仍然可以通过http运行网站,在我的工作机器上,它根本不会通过http运行,只有https。

还有什么人可以想到为什么会这样吗?

2 个答案:

答案 0 :(得分:2)

基于错误"这可能是服务器的问题,或者可能需要您没有的客户端身份验证证书"而且它在你朋友的电脑上运行而不是你的电脑这一事实让我相信它是你计算机上的SSL密钥和证书的问题。您可以使用以下教程生成自己的教程:http://www.akadia.com/services/ssh_test_certificate.html

key: grunt.file.read('server.key').toString(),
cert: grunt.file.read('server.crt').toString(),
ca: grunt.file.read('ca.crt').toString()

确保上述文件位于运行grunt的基本文件夹中。使用您使用上述教程创建的证书颁发机构对自己的证书进行自签名时,ca.crt文件也是必需的。希望这有帮助!

答案 1 :(得分:0)

我会首先查找日志文件并在您发出请求时尾随。它可能会给你一些关于错误的提示

相关问题