关于ssl:让Chrome接受自签名的localhost证书

Getting Chrome to accept self-signed localhost certificate

我已经为localhost cn创建了一个自签名的SSL证书。如预期的那样,firefox在最初抱怨这个证书之后接受它。然而,Chrome和IE拒绝接受它,即使在将证书添加到受信任根目录下的系统证书存储之后也是如此。尽管当我在chrome的https弹出窗口中单击"查看证书信息"时,证书被列为正确安装,但它仍然坚持证书不能被信任。

我该怎么做才能让Chrome接受证书并停止抱怨?


仅适用于localhost

只需将其粘贴到Chrome中:

1
chrome://flags/#allow-insecure-localhost

您应该看到突出显示的文本说:允许从本地主机加载的资源使用无效证书

单击Enable


这对我很有用:

  • 使用chrome,通过https点击服务器上的一个页面,然后继续浏览红色警告页面(假设您还没有这样做)。
  • 打开Chrome Settings > Show advanced settings > HTTPS/SSL > Manage Certificates
  • 单击Authorities选项卡并向下滚动以在您提供给证书的组织名称下找到您的证书。
  • 选择它,单击编辑(注意:在最新版本的Chrome中,按钮现在是"高级"而不是"编辑"),选中所有框并单击确定。您可能需要重新启动chrome。
  • 你现在应该在你的页面上找到绿色的锁了。

    编辑:我在一台新计算机上再次尝试了此操作,但证书没有显示在"管理证书"窗口中,只是从红色的不受信任的证书页继续。我必须做以下工作:

  • 在具有不可信证书的页面(https://以红色划掉),单击锁定>证书信息。注意:在较新版本的Chrome上,必须打开Developer Tools > Security,然后选择View certificate
  • 单击Details tab > Export。选择PKCS #7, single certificate作为文件格式。
  • 然后按照原始说明进入管理证书页面。单击Authorities tab > Import并选择导出证书的文件,并确保选择PKCS #7, single certificate作为文件类型。
  • 如果提示证书存储,请选择受信任的根证书颁发机构
  • 选中所有框并单击"确定"。重新启动Chrome。

  • 在Mac上,您可以使用keychain访问实用程序将自签名证书添加到系统keychain,然后chrome将接受它。我在这里找到了分步说明:

    Google Chrome、Mac OS X和自签名SSL证书

    基本上:

  • 双击带有x的锁定图标,然后将证书图标拖放到桌面上,
  • 打开此文件(以.cer扩展名结尾);这将打开允许您批准证书的密钥链应用程序。

  • Chrome 58+更新(2017-04-19发布)

    从Chrome58开始,只使用commonName标识主机的操作将被删除。请参阅此处的进一步讨论和此处的bug跟踪器。过去,subjectAltName仅用于多主机证书,因此某些内部CA工具可能不包括它们。

    如果您的自签名证书在过去工作得很好,但突然开始在Chrome58中产生错误,这就是为什么。

    因此,无论您使用什么方法来生成自签名证书(或由自签名CA签名的证书),都要确保服务器的证书包含一个带有正确的DNS和/或IP条目/条目的subjectAltName,即使它只针对一个主机。

    对于openssl,这意味着您的openssl配置(Ubuntu上的/etc/ssl/openssl.cnf)对于单个主机应该具有类似于以下内容的内容:

    1
    2
    [v3_ca]   # and/or [v3_req], if you are generating a CSR
    subjectAltName = DNS:example.com

    或者对于多个主机:

    1
    2
    [v3_ca]   # and/or [v3_req], if you are generating a CSR
    subjectAltName = DNS:example.com, DNS:host1.example.com, DNS:*.host2.example.com, IP:10.1.2.3

    在chrome的cert-viewer中(在f12下已移动到"security"选项卡),您应该看到它在Extensions下作为Certificate Subject Alternative Name列出:

    Chrome cert viewer


    UPDATE 11/2017: This answer probably won't work for most newer versions of Chrome.

    UPDATE 02/2016: Better Instructions for Mac Users Can be Found Here.

  • 在要添加的站点上,右键单击地址栏中的红色锁定图标:enter image description here

  • 单击标记为"连接"的选项卡,然后单击"证书信息"

  • 单击"详细信息"选项卡,单击"复制到文件…"按钮。这将打开证书导出向导,单击下一步进入导出文件格式屏幕。

  • 选择der编码二进制x.509(.cer),单击下一步

  • 单击浏览…并将文件保存到您的计算机。把它命名为描述性的。单击下一步,然后单击完成。

  • 打开Chrome设置,滚动到底部,然后单击显示高级设置…

  • 在https/ssl下,单击管理证书…

  • 单击可信根证书颁发机构选项卡,然后单击导入…按钮。这将打开证书导入向导。单击"下一步"进入"要导入的文件"屏幕。

  • 单击浏览…并选择先前保存的证书文件,然后单击下一步。

  • 选择将所有证书放置在以下存储中。所选存储应该是受信任的根证书颁发机构。如果不是,请单击浏览…然后选择它。单击"下一步"并完成

  • 单击"安全警告"上的"是"。

  • 重新启动Chrome。


  • Linux

    如果您使用的是Linux,您还可以按照以下官方wiki页面操作:

    • 在Linux上配置SSL证书。
    • NSS共享数据库和Linux
    • NSS共享数据库howto

    基本上:

    • 单击带有X的锁定图标,
    • 选择证书信息
    • 转到"详细信息"选项卡
    • 单击导出…(另存为文件)

    现在,下面的命令将添加证书(其中您的_文件是导出的文件):

    1
    certutil -d sql:$HOME/.pki/nssdb -A -t"P,," -n YOUR_FILE -i YOUR_FILE

    要列出所有证书,请运行以下命令:

    1
    certutil -d sql:$HOME/.pki/nssdb -L

    如果仍然不起作用,您可能会受到此错误的影响:问题55050:Ubuntu SSL错误8179

    另外,在使用上述命令之前,请确保您有libnss3-tools

    如果没有,请通过以下方式安装:

    1
    2
    sudo apt-get install libnss3-tools # on Ubuntu
    sudo yum install nss-tools # on Fedora, Red Hat, etc.

    另外,您还可以使用以下方便的脚本:

    1
    2
    3
    4
    5
    6
    $ cat add_cert.sh
    certutil -d sql:$HOME/.pki/nssdb -A -t"P,," -n $1 -i $1
    $ cat list_cert.sh
    certutil -d sql:$HOME/.pki/nssdb -L # add '-h all' to see all built-in certs
    $ cat download_cert.sh
    echo QUIT | openssl s_client -connect $1:443 | sed -ne '/BEGIN CERT/,/END CERT/p'

    用途:

    1
    2
    3
    add_cert.sh [FILE]
    list_cert.sh
    download_cert.sh [DOMAIN]

    故障排除

    • --auto-ssl-client-auth参数运行chrome

      google-chrome --auto-ssl-client-auth


    单击页面上的任意位置并键入旁路序列

    "thisisunsafe是Chrome 65版的旁路序列。

    "badidea"Chrome版本62-64。

    "danger用于早期版本的chrome

    您不需要查找输入字段,只需键入即可。感觉很奇怪,但它起作用了。

    我在麦克·西拉上试过。

    要再次检查是否更改,请转到最新的铬源代码。

    要查找旁路序列,目前看起来如下:

    1
    var BYPASS_SEQUENCE = window.atob('dGhpc2lzdW5zYWZl');

    现在他们已经把它伪装了,但是要想看到真正的旁路序列,你可以在浏览器控制台中运行以下行。

    1
    console.log(window.atob('dGhpc2lzdW5zYWZl'));


    在Mac上,您可以通过执行以下操作创建一个完全受Chrome和Safari在系统级别信任的证书:

    1
    2
    3
    4
    5
    6
    7
    8
    # create a root authority cert
    ./create_root_cert_and_key.sh

    # create a wildcard cert for mysite.com
    ./create_certificate_for_domain.sh mysite.com

    # or create a cert for www.mysite.com, no wildcards
    ./create_certificate_for_domain.sh www.mysite.com www.mysite.com

    以上使用以下脚本和支持文件v3.ext避免主题替换名丢失错误。

    如果要使用自己的根权限创建完全受信任的新自签名证书,可以使用这些脚本来创建。

    创建根目录cert和key.sh

    1
    2
    3
    #!/usr/bin/env bash
    openssl genrsa -out rootCA.key 2048
    openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem

    为domain.sh创建u证书

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    #!/usr/bin/env bash

    if [ -z"$1" ]
    then
      echo"Please supply a subdomain to create a certificate for";
      echo"e.g. www.mysite.com"
      exit;
    fi

    if [ ! -f rootCA.pem ]; then
      echo 'Please run"create_root_cert_and_key.sh" first, and try again!'
      exit;
    fi
    if [ ! -f v3.ext ]; then
      echo 'Please download the"v3.ext" file and try again!'
      exit;
    fi

    # Create a new private key if one doesnt exist, or use the xeisting one if it does
    if [ -f device.key ]; then
      KEY_OPT="-key"
    else
      KEY_OPT="-keyout"
    fi

    DOMAIN=$1
    COMMON_NAME=${2:-*.$1}
    SUBJECT="/C=CA/ST=None/L=NB/O=None/CN=$COMMON_NAME"
    NUM_OF_DAYS=999
    openssl req -new -newkey rsa:2048 -sha256 -nodes $KEY_OPT device.key -subj"$SUBJECT" -out device.csr
    cat v3.ext | sed s/%%DOMAIN%%/"$COMMON_NAME"/g > /tmp/__v3.ext
    openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days $NUM_OF_DAYS -sha256 -extfile /tmp/__v3.ext

    # move output files to final filenames
    mv device.csr"$DOMAIN.csr"
    cp device.crt"$DOMAIN.crt"

    # remove temp file
    rm -f device.crt;

    echo
    echo"###########################################################################"
    echo Done!
    echo"###########################################################################"
    echo"To use these files on your server, simply copy both $DOMAIN.csr and"
    echo"device.key to your webserver, and use like so (if Apache, for example)"
    echo
    echo"    SSLCertificateFile    /path_to_your_files/$DOMAIN.crt"
    echo"    SSLCertificateKeyFile /path_to_your_files/device.key"

    V3.EXT

    1
    2
    3
    4
    5
    6
    7
    authorityKeyIdentifier=keyid,issuer
    basicConstraints=CA:FALSE
    keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
    subjectAltName = @alt_names

    [alt_names]
    DNS.1 = %%DOMAIN%%

    还有一个步骤-如何在chrome/safari中完全信任自签名证书

    要允许在Chrome和Safari中完全信任自签名证书,需要将新的证书颁发机构导入Mac。要执行此操作,请遵循以下说明,或Mitmproxy网站上有关此常规流程的更详细说明:

    在命令行中,您可以使用提示您输入密码的命令执行以下两种操作之一:

    1
    $ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem

    或者使用Keychain Access应用程序:

  • 打开钥匙链访问
  • 在"钥匙链"列表中选择"系统"
  • 在"类别"列表中选择"证书"
  • 选择"文件导入项目…"
  • 浏览到上面创建的文件"rootca.pem",选择它,然后单击"打开"
  • 在"证书"列表中选择新导入的证书。
  • 单击"i"按钮,或右键单击证书,然后选择"获取信息"
  • 扩展"信任"选项
  • 将"使用此证书时"更改为"始终信任"
  • 关闭对话框,系统会提示您输入密码。
  • 关闭并重新打开使用目标域的所有选项卡,它将被安全加载!
  • 作为奖励,如果您需要Java客户端信任证书,您可以通过将证书导入到Java密钥存储库中。注意:如果证书已经存在,它将从密钥库中删除证书,因为它需要在情况发生变化时更新它。当然,它只对导入的证书执行此操作。

    将"当前"文件夹中的"证书"导入到"java"keystore.sh中

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    KEYSTORE="$(/usr/libexec/java_home)/jre/lib/security/cacerts";

    function running_as_root()
    {
      if ["$EUID" -ne 0 ]
        then echo"NO"
        exit
      fi

      echo"YES"
    }

    function import_certs_to_java_keystore
    {
      for crt in *.crt; do
        echo prepping $crt
        keytool -delete -storepass changeit -alias alias__${crt} -keystore $KEYSTORE;
        keytool -import -file $crt -storepass changeit -noprompt --alias alias__${crt} -keystore $KEYSTORE
        echo
      done
    }

    if ["$(running_as_root)" =="YES" ]
    then
      import_certs_to_java_keystore
    else
      echo"This script needs to be run as root!"
    fi


    如果您在Mac电脑上,没有看到导出选项卡或如何获取证书,这对我很有用:

  • 单击https://前面的锁/
  • 转到"连接"选项卡
  • 点击"证书信息"

    现在您应该看到:Different information of course and yours should be marked as trusted yet (otherwise      you probably wouldn't be here)

  • 拖动那个小证书图标做你的桌面(或任何地方)。

  • 双击下载的.cer文件,将其导入到您的keychain中,并打开keychain访问您的证书列表。

    在某些情况下,这就足够了,现在您可以刷新页面。

    否则:

  • 双击新添加的证书。
  • 在"信任"下拉列表下,将"使用此证书时"选项更改为"始终信任"
  • 现在重新加载有问题的页面,问题应该解决了!希望这有帮助。

    沃尔夫编辑

    要使其更简单,可以使用以下脚本(源代码):

  • 将以下脚本另存为whitelist_ssl_certificate.ssh

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    #!/usr/bin/env bash -e

    SERVERNAME=$(echo"$1" | sed -E -e 's/https?:\/\///' -e 's/\/.*//')
    echo"$SERVERNAME"

    if [["$SERVERNAME" =~ .*\..* ]]; then
        echo"Adding certificate for $SERVERNAME"
        echo -n | openssl s_client -connect $SERVERNAME:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | tee /tmp/$SERVERNAME.cert
        sudo security add-trusted-cert -d -r trustRoot -k"/Library/Keychains/System.keychain" /tmp/$SERVERNAME.cert
    else
        echo"Usage: $0 www.site.name"
        echo"http:// and such will be stripped automatically"
    fi
  • 使脚本可执行(从shell):

    1
    chmod +x whitelist_ssl_certificate.ssh
  • 为所需域运行脚本(只需复制/粘贴完整的URL即可):

    1
    ./whitelist_ssl_certificate.ssh https://your_website/whatever

  • 更新日期:2018年4月3日

    铬组推荐

    https://www.chromium.org/home/chromium security/deprecating powerfull features on unsecure origins toc测试强大功能

    快速超简单解决方案

    有一个秘密的旁路短语,可以输入错误页面,让chrome继续运行,尽管有安全错误:thisisunsafe(在chrome的早期版本中,输入baddidea,甚至更早的版本是danger)。除非你完全理解你为什么需要它,否则不要使用它!

    来源:

    https://chromium.googlesource.com/chromium/src/+/d8fc089b62cd4f8d907acf6fb3f5ff58f168697%5e%21/

    (注意,window.atob('dGhpc2lzdW5zYWZl')决议为thisisunsafe)

    最新版本的源代码是@https://chromium.googlesource.com/chromium/src/+/refs/heads/master/components/security_interitials/core/browser/resources/intermediate_large.js,可以在JS控制台中执行window.atob功能。

    有关chrome团队更改旁路短语(第一次)的背景:

    https://bugs.chromium.org/p/chromium/issues/detail?ID=581189

    如果其他都失败了

    对于快速一次性,如果"无论如何继续"选项不可用,或者旁路短语工作正常,则此黑客程序工作良好:

  • 通过启用此标志,允许来自localhost的证书错误(注意chrome需要在更改标志值后重新启动):

    chrome://flags/#allow-insecure-localhost

    (并由@chris投票选出答案https://stackoverflow.com/a/31900210/430128)

  • 如果你想连接的站点是localhost,你就完成了。否则,设置一个TCP隧道本地监听端口8090,并连接到端口443上的broken-remote-site.com,确保已安装socat,并在终端窗口中运行类似的程序:

    socat tcp-listen:8090,reuseaddr,fork tcp:broken-remote-site.com:443

  • 在浏览器中转到https://localhost:8090。


  • 对于测试环境

    启动chrome时,可以使用--ignore-certificate-errors作为命令行参数(在Ubuntu上使用版本28.0.1500.52)。

    这将导致它忽略错误并在没有警告的情况下连接。如果已经在运行Chrome版本,则需要在从命令行重新启动之前关闭它,否则它将打开一个新窗口,但忽略参数。

    我将Intellij配置为在调试时以这种方式启动chrome,因为测试服务器从来没有有效的证书。

    不过,我不建议像这样进行正常浏览,因为证书检查是一项重要的安全功能,但这可能对某些人有所帮助。


    正如有人指出的,您需要重新启动所有的Chrome,而不仅仅是浏览器窗口。最快的方法是打开一个标签…

    chrome://restart


    (P)Windows Jun/2017 Windows Server 2012(p)(P)我跟着Brad Parks AnswerOn windows you should import rootca.pem in trusted root certificates authorities store.(p)(P)I did the following steps:(p)字母名称(P)Where V3.EXT is:(p)字母名称(P)Then,in my case I have a self hosted web app,so I need to bind certificate with IP address and port,certificate should be on my store with private key in format i on,so I exported to PFX format.(p)字母名称(P)With MMC console(file/Add or remove snap-INS/certificates/Add/computert account/localcompaputer/OK)I imported PFX file in personal store.(p)(P)Later I used this command to bind certificate(you could also use httconfig tool):(p)字母名称(P)Certhash=Certificate Thumpint(p)(P)Appid=guid(Your choice)(p)(P)第一次尝试进口认证"Device.crt"on trusted root certificates authorities in different ways but I'm still get same mistake:(p)(P)字母名称(p)(P)但我确实认为,我应该进口Root Authority的证书,而不是农村地区的证书。So I used MMC console(file/Add or remove snap-INS/certificates/Add/computer account/localcompaputer/OK)i imported rootca.pem in trusted root certificates authorities store.(p)(P)字母名称(p)(P)Restat chrome and et voilàit works.(p)(P)With localhost:(p)(P)MGXY1音标2(p)(P)Or with IP address:(p)(P)MGXY1音标3(p)(P)The only thing I could not achieve is that,it has过时(Red Square on Picture).Help is appreciated on this point.(p)(P)With maker cert it is not possible add San Information.With new-selfsignedcertificate(PowerShell)you could add San Information,it also works.(p)


    您确定站点的地址与证书地址相同吗?我对Chrome和自签名证书也有同样的问题,但最终我发现它对证书上的域名验证(应该是这样)非常挑剔。

    Chrome没有自己的证书存储,使用window自己的。然而,Chrome没有提供将证书导入存储的方法,因此您应该通过IE添加它们。

    在Google Chrome中安装证书

    在Internet Explorer中安装证书

    另外,请看一下创建自签名证书的几种不同方法(我假设您使用的是IIS,正如您没有提到的那样)。

    如何在IIS 7中创建自签名证书


    当单击URL旁边的小交叉锁图标时,您会看到一个如下所示的框:

    enter image description here

    单击证书信息链接后,您将看到以下对话框:

    enter image description here

    它告诉您哪个证书存储是正确的,它是受信任的根证书颁发机构存储。

    您可以使用其他答案中概述的方法之一将证书添加到该存储,也可以使用:

    1
    certutil -addstore -user"ROOT" cert.pem
    • ROOT是前面提到的证书存储的内部名称。
    • cert.pem是您的自签名证书的名称。


    我按照比约诺德的建议去做,这是:Google Chrome、Mac OS X和自签名SSL证书

    博客中显示的内容不起作用。

    然而,博客上的一条评论是黄金:

    sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain site.crt

    你需要在博客上关注如何获取证书文件,然后你可以使用上面的命令,并且应该可以很好地使用。


    (P)This post is already flooded with responses,but I created a bash script based on some of the other answers to make it easier to generate a self-signed TLS certificate valid in chrome(tested in EDOCX1 silios).希望对其他人有用。(p)布尔奇1(P)在你安装(和信任)证书后,不必再减去(EDOCX1)英字体。(p)(P)Another tool worth checking out is cloudflare's EDOCX1(p)布尔奇1


    在Linux上管理chromium上的ssl证书的gui不适合我。然而,他们的医生给出了正确的答案。诀窍是运行下面导入自签名SSL证书的命令。只需更新certificate-filename.cer的名称,然后重新启动chromium/chrome。

    来自文档:

    On Linux, Chromium uses the NSS Shared DB. If the built-in manager does not work for you then you can configure certificates with the NSS command line tools.

    Get the tools

    • Debian/Ubuntu: sudo apt-get install libnss3-tools

    • Fedora: su -c"yum install nss-tools"

    • Gentoo: su -c"echo 'dev-libs/nss utils' >> /etc/portage/package.use && emerge dev-libs/nss" (You need to launch all commands below with the nss prefix, e.g., nsscertutil.)
      Opensuse: sudo zypper install mozilla-nss-tools

    To trust a self-signed server certificate, we should use

    certutil -d sql:$HOME/.pki/nssdb -A -t"P,," -n -i certificate-filename.cer

    List all certificates

    certutil -d sql:$HOME/.pki/nssdb -L

    The TRUSTARGS are three strings of zero or more alphabetic characters, separated by commas. They define how the certificate should be trusted for SSL, email, and object signing, and are explained in the certutil docs or Meena's blog post on trust flags.

    Add a personal certificate and private key for SSL client authentication
    Use the command:

    pk12util -d sql:$HOME/.pki/nssdb -i PKCS12_file.p12

    to import a personal certificate and private key stored in a PKCS #12 file. The TRUSTARGS of the personal certificate will be set to"u,u,u".

    Delete a certificate
    certutil -d sql:$HOME/.pki/nssdb -D -n

    摘录自:https://chromium.googlesource.com/chromium/src/+/head/docs/linux_cert_management.md


    (P)As of chrome 58+I started getting certificate on macos due missing San.这里是如何得到绿色的锁在解决酒吧的再次。(p)

  • (P)Generatite a new certificate with the following command:(p)字母名称
  • (P)Import the EDOCX1 pensional 0 into your keychain,they double click in the certificate,expand the trust,and select always trust(p)
  • (P)Refresh the page https://domain.dev in google chrome,so the green lock is back.(p)


    我尝试了所有方法和使其生效的方法:导入时,选择正确的类别,即受信任的根证书颁发机构:

    (不好意思,这是德语,但请按照图片操作)

    enter image description here


    允许不安全的本地主机通过chrome://flags/允许不安全的本地主机正常工作

    只需将开发主机名创建到xxx.localhost。


    这是一个不断出现的东西——尤其是对于Mac OS X Yosemite上的Google Chrome!

    谢天谢地,我们的一个开发团队今天给我发了这个链接,这个方法工作可靠,同时还允许您控制接受证书的站点。

    杰斯利邮报:

    If you don't want to bother with internal certificates...

  • Type chrome://flags/ in the address bar.
  • Scroll to or search for Remember decisions to proceed through SSL errors for a specified length of time.
  • Select Remember for three months.

  • 当我试图在浏览器中导入证书时,它不起作用…在chrome中打开开发人员工具>安全性,然后选择查看证书。单击"详细信息"选项卡并将其导出。

    /Linux

    1
    2
    3
    sudo apt-get install libnss3-tools

    certutil -d sql:$HOME/.pki/nssdb -A -t"P,," -n [EXPORTED_FILE_PATH] -i [EXPORTED_FILE_PATH]

    运行这个命令,如果你看到你刚导入的文件,你就可以走了!

    1
     certutil -d sql:$HOME/.pki/nssdb -L

    //Windows

    1
    Start => run => certmgr.msc

    在左侧选择可信根证书颁发机构=>个人。单击操作选项卡=>所有操作/导入,然后从浏览器中选择之前导出的文件

    别忘了重新启动Chrome!!!!

    祝你好运!;)


    这对我很有效。参见:http://www.robbick.com/2010/10/google-chrome-mac-os-x-and-self-signed-ssl-certificates/.vcy8_znvhbc

    在地址栏中,单击带有X的小锁。这将显示一个小信息屏幕。单击"证书信息"按钮。

    单击并将图像拖到桌面上。它看起来像一个小证书。

    双击它。这将显示keychain访问实用程序。输入密码以解锁。

    请确保将证书添加到系统密钥链,而不是登录密钥链。点击"永远信任",即使这看起来没什么作用。

    添加后,双击它。您可能需要再次验证。

    展开"信任"部分。

    使用此证书时,设置为"始终信任"


    (P)2017-06-27 Newest Method:(p)字母名称(P)Then,add yoursite.crt and yoursite.key to your nginx conf.(p)(P)From:https://github.com/webpack/webpack-dev-server/issues/854(p)


    我不得不在MacOSX上调整chrome启动程序,并在下面添加了脚本。保存如下:

    /Applications/Google\ Chrome.app/Contents/MacOS/Chrome.command

    1
    2
    3
    4
    #!/bin/sh
    RealBin="Google Chrome"
    AppDir="$(dirname"$0")"
    exec"$AppDir/$RealBin" --ignore-certificate-errors"$@"

    当我用这个脚本启动chrome时,自签名证书工作正常。但是不要用这个脚本启动的浏览器浏览网页,你不会收到关于无效证书的警告!


    Mac/OSX上的SSL/HTTPS本地主机修复程序:

  • 尝试打开HTTPS本地主机环境时,单击地址栏中带有十字的红色锁。将打开一个窗口,其中包含有关证书的一些信息。

  • 点击"详细信息"信息窗口

  • Chrome开发人员工具将在"安全"选项卡上打开。单击查看证书。证书图像
  • 将其添加到您的"系统"密钥链(而不是默认选择的"登录"密钥链)。

  • 再次打开钥匙链,找到证书。点击它,确保你"信任"所有人。

  • 重新启动Chrome,它应该可以工作。


  • 修复Windows上的Chrome。

    首先,您需要导出证书。

    • 在浏览器中找到URL。URL的"https"段将用红线划掉,左边会有一个锁符号。
    • 右键单击划掉的"https"段。
    • 您将看到一个包含各种信息的信息窗口
    • 单击"详细信息"。
    • 导出证书,按照说明接受默认设置。

    进口

    • 转到Chrome设置
    • 单击"高级设置"
    • 在https/ssl下,单击"管理证书"
    • 转到"受信任的根证书颁发机构"
    • 点击"导入"
    • 将出现一个弹出窗口,询问您是否要安装此证书。单击"是"。


    为了在Windows上进行开发,可以添加到chrome快捷标志--ignore-certificate-errors

    它希望忽略证书错误并允许您访问无效的证书网站。在https://support.opendns.com/entries/66657664中有更详细的说明。

    enter image description here


    What am I supposed to do to get Chrome to accept the certificate and stop complaining about it?

    您应该用创建一个pki;

    1)自签名根CA。2)次级/中间证书[由根CA签署]。3)普通/最终实体证书[由根CA或子CA签署](CommonName或SubjectAltname(SAN)作为本地主机)(还包括https://localhost/作为SAN中的URI)。4)在您的Windows操作系统中导入/安装根CA(因为您提到过,即Google Chrome在查找证书链时使用相同的资源-https://www.chromium.org/home/chromium-security/root-ca-policy)作为"受信任的根证书颁发机构"。5)安装该最终实体证书作为您的Web服务器证书,它停止抱怨错误消息。

    希望这有帮助。


    我自己解决了这个问题,没有更改任何具有适当SSL认证的浏览器上的设置。我使用的是Mac,所以它需要对我的SSL认证进行密钥链更新。为了让Chrome接受它,我必须将使用者alt名称添加到SSL认证中。从今天起,这是用于Chrome版本号:62.0.3202.94

    我的示例易于使用命令和配置文件:

    添加这些文件,这个示例都在一个根目录中

    SSL.CONF

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    [ req ]
    default_bits       = 4096
    distinguished_name = req_distinguished_name
    req_extensions     = req_ext

    [ req_distinguished_name ]
    countryName                 = Country Name (2 letter code)
    stateOrProvinceName         = State or Province Name (full name)
    localityName                = Locality Name (eg, city)
    organizationName            = Organization Name (eg, company)
    commonName                  = Common Name (e.g. server FQDN or YOUR name)
    commonName_max              = 64

    [ req_ext ]
    subjectAltName = @alt_names

    [alt_names]
    DNS.1   = localhost

    运行命令以创建证书:

    1
    openssl req -newkey rsa:4096 -nodes -keyout key.pem -x509 -days 3650 -out certificate.pem -extensions req_ext -config ssl.conf -subj '/CN=localhost/O=Stackflow/C=US/L=Los Angeles/OU=StackflowTech'

    对于Mac,仅添加受信任的证书(必需):

    1
    sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./certificate.pem

    对于Windows,您必须找到如何在本地独立地验证我们的SSL证书。我不用窗户。不好意思,Windows的伙计们。

    我使用的是带有express.js的node.js服务器,它只需要我的密钥和以下证书:

    App.JS

    1
    2
    3
    4
    5
    6
    7
    8
    9
    const https = require('https');
    const Express = require('express');
    const fs = require('fs');
    const app = new Express();
    const server = https.createServer({
        key: fs.readFileSync('./key.pem'),
        cert: fs.readFileSync('./certificate.pem'),
    }, app);
    server.listen(3000);

    我可能在将来为其他后端框架做这个,所以我可以在将来为其他人更新这个示例。但这是我在node.js中针对该问题的修复。清除浏览器缓存并在https://上运行应用程序/

    以下是在node.js服务器上为Mac用户运行https://localhost的示例:

    https://github.com/laynefaler/stack-overflow-running-https-localhost

    快乐编码!


    对于MacOS上的Chrome,如果您准备了证书:

    • 退出chrome(cmd+q)。
    • 启动钥匙链访问应用程序并打开"证书"类别。
    • 将证书文件拖到"钥匙链访问"窗口,然后键入证书文件的密码。
    • 双击证书并展开"信任"列表。
      • 在"使用此证书时"行中,选择"始终信任"。
      • 关闭此文件并键入密码。
    • 启动chrome并清除所有缓存。
    • 检查一切正常。

    凯伦的回答和托比J的重要更新使我获得了成功,但我必须进行修订:

    创建自签名证书时,需要将新的subjectAltName字段放在v3_ca扩展名下,而不是v3_req。我把/etc/ssl/openssl.conf复制到一个临时文件中,然后在[ v3_ca ]下添加了一行subjectAltName = DNS:*.example.com。然后将该文件传递给cert creation命令,类似于

    1
    2
    3
      openssl req -x509 -nodes -newkey rsa:2048 \
              -config /tmp/openssl-revised.cfg \
              -keyout example.com.key -out example.com.crt

    并遵循凯伦的最新步骤。


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    mkdir CA
    openssl genrsa -aes256 -out CA/rootCA.key 4096
    openssl req -x509 -new -nodes -key CA/rootCA.key -sha256 -days 1024 -out CA/rootCA.crt

    openssl req -new -nodes -keyout example.com.key -out domain.csr -days 3650 -subj"/C=US/L=Some/O=Acme, Inc./CN=example.com"
    openssl x509 -req -days 3650 -sha256 -in domain.csr -CA CA/rootCA.crt -CAkey CA/rootCA.key -CAcreateserial -out example.com.crt -extensions v3_ca -extfile <(
    cat <<-EOF
    [ v3_ca ]
    subjectAltName = DNS:example.com
    EOF
    )

    我也遇到了同样的问题:我将证书安装到了Windows的可信根授权存储中,而Chrome仍然拒绝证书,错误为ERR_CERT_COMMON_NAME_INVALID。注意,如果证书没有正确安装在存储中,则错误为ERR_CERT_AUTHORITY_INVALID

    正如错误名称、此注释和此问题所暗示的那样,问题在于证书中声明的域名。生成证书时,当提示输入"公用名"时,我必须输入我用来访问该站点的域名(在我的例子中是localhost)。我使用chrome://restart重新启动了chrome,它最终对这个新证书感到满意。


    对于Fedora和Ubuntu,如果在使用GUI添加新的根权限时遇到example.com Not a Certification authority错误。

    使用从chrome导出的证书尝试以下操作,任何格式都有效(base64-chain/singe、pkcs 7、der-binary等)。当所有的GUI方法都不幸失败时,这对我很有效。

    1
    2
    certutil -d sql:$HOME/.pki/nssdb -A -t"P,," -n <certificate nickname> \
    -i <certificate filename>

    要查看更改,请重新启动chrome,必要时从后台将其杀死。火狐仍然会抱怨。

    如果以后需要删除它,请转到chrome->settings->advanced->manage certificates->servers,它最终会显示在那里,在那里可以删除它。

    来源,警告,非常零散和部分过时:https://chromium.googlesource.com/chromium/src/+/head/docs/linuxu certu management.md


    (P)Here is a solution using only Java 8 keytool.exe instead of openssl:(p)字母名称(P)You could also use pipes instead of files,but with the files,you can check the intermediate results if some goes wrong.SSL tested with IE11,EDGE,FF54,chrome60 on windows and chrome60 on Android.(p)(P)请在使用脚本之前更改密码。(p)


    (P)我不知道答案在哪里,在视窗10(p)(P)字母名称4(p)(P)However I found this page,indicating another flag to pass:(p)(P)http://www.chromium.org/blink/servicworker/service-worker-faq(p)布尔奇1(P)That did not get rid of the Red Warning,but it did enable me to use https-only feature like service workers and web push notifications.(p)


    假设您在Mac OSX上,您也可以在Safari中打开有问题的URL;比如:https://localhost:8080/css/app.css,允许cert.re-start chrome,它就会工作。