A
A
Alexey Yarkov2017-02-11 14:21:40
local server
Alexey Yarkov, 2017-02-11 14:21:40

How to make an SSL certificate on localhost for browserSync?

I generate a certificate and a key with the following script:

#!/bin/bash

CWD="$1"
HOST="$2"

key="${CWD}/${HOST}.key"
crt="${CWD}/${HOST}.crt"

rm -f "${key}" "${crt}"

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "${key}" -out "${crt}" -subj "/[email protected]${HOST}/CN=${HOST}/OU=${HOST}/O=${HOST}/L=${HOST}/ST=${HOST}/C=ru"

This is how I start browserSync:
browserSync({
        browser: "google-chrome",
        server: {
          baseDir: "./build"
        },
        port: 3030,
        open: true,
        notify: true,
        https: {
          key: options.browserSync.key,
          cert: options.browserSync.crt
        }
      });

And I have a beautiful error:
1743b9bec8784a87b6357f6f0e943c4a.png
How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CityCat4, 2017-02-11
@yarkov

And you, sorry, what did you expect to see? A self-generated certificate is not trusted. Add it first to the trusted root centers - and try later, maybe it will work.
By the way, the text of the error is not visible, I just assumed that it was CERT_AUTHORITY_INVALID

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question