gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 146 forks source link

Privacy error when trying to configure SSL #225

Closed jrdn91 closed 5 years ago

jrdn91 commented 7 years ago

I get the privacy error in chrome when trying to load the server. I followed the readme docs for generatice a cert and key and all that and have the settings as such

connect: {
      options: {
        protocol: 'https', // or 'http2'
        port: 8443,
        key: grunt.file.read('server.key').toString(),
        cert: grunt.file.read('server.crt').toString(),
        ca: grunt.file.read('ca.crt').toString(),
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          open: true,
          port: 8443,
          key: grunt.file.read('server.key').toString(),
          cert: grunt.file.read('server.crt').toString(),
          middleware: function (connect) {
            return [
              modRewrite(['^[^\\.]*$ /index.html [L]']),
              connect.static('.tmp'),
              connect().use(
                '/bower_components',
                connect.static('./bower_components')
              ),
              connect().use(
                '/app/styles',
                connect.static('./app/styles')
              ),
              connect.static(appConfig.app)
            ];
          }
        }
      },
...

My livereload settings look like this

watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['wiredep']
      },
      js: {
        files: ['<%= yeoman.app %>/scripts/**/*.js'],
        tasks: ['newer:jshint:all', 'newer:jscs:all'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'newer:jscs:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.scss'],
        tasks: ['sass:dev']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/**/*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

I'm using the Yeoman Angular generator, which created this layout.

I've also added both the server.crt and ca.crt to my keychain access un the system keychanin, and given them both Always Trust permissions, and restarted Chrome after to make sure.

Maybe there is something with the way the connect server is being configured that the yeoman generator is doing a little different than the readme is explaining? Can anyone make sense of this?

KrzysztofKarol commented 6 years ago

It's because Chrome and other browsers doesn't "support" old versions. See: https://www.ssl.com/how-to/turn-off-ssl-3-0-and-tls-1-0-in-your-browser/#CH

Better solution: https://serverfault.com/questions/845766/generating-a-self-signed-cert-with-openssl-that-works-in-chrome-58

I guess README https://github.com/gruntjs/grunt-contrib-connect#support-for-https--http2 should be somehow updated

XhmikosR commented 5 years ago

Duplicate of #193.