Getting Chrome to accept self-signed localhost certificate

后端 未结 30 2921
小蘑菇
小蘑菇 2020-11-21 11:30

I have created a self-signed SSL certificate for the localhost CN. Firefox accepts this certificate after initially complaining about it, as expected. Chrome and IE, however

30条回答
  •  礼貌的吻别
    2020-11-21 12:03

    To create a self signed certificate in Windows that Chrome v58 and later will trust, launch Powershell with elevated privileges and type:

    New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -Subject "fruity.local" -DnsName "fruity.local", "*.fruity.local" -FriendlyName "FruityCert" -NotAfter (Get-Date).AddYears(10)
    #notes: 
    #    -subject "*.fruity.local" = Sets the string subject name to the wildcard *.fruity.local
    #    -DnsName "fruity.local", "*.fruity.local"
    #         ^ Sets the subject alternative name to fruity.local, *.fruity.local. (Required by Chrome v58 and later)
    #    -NotAfter (Get-Date).AddYears(10) = make the certificate last 10 years. Note: only works from Windows Server 2016 / Windows 10 onwards!!
    

    Once you do this, the certificate will be saved to the Local Computer certificates under the Personal\Certificates store.

    You want to copy this certificate to the Trusted Root Certification Authorities\Certificates store.

    One way to do this: click the Windows start button, and type certlm.msc. Then drag and drop the newly created certificate to the Trusted Root Certification Authorities\Certificates store per the below screenshot.

提交回复
热议问题