Getting Chrome to accept self-signed localhost certificate

后端 未结 30 3369
小蘑菇
小蘑菇 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 11:52

    For Fedora, Ubuntu, Linux, if you're getting example.com Not a Certification authority error when adding the certificate using the gui to add a new root authority. If you want to trust a server self signed certificate, it cannot make mention of an invalid authority... even if that's itself. I've only managed to make it work by trusting my authority and using that authorities key to sign server certificates.

    Here's the self signed CA certificate that it accepted. This is the only way that I found works to get around cert_authority_invalid, I tried for hours to get it to accept a self signed end point certificate, no cigar. The UI will accept self signed authorities, as long as it's declared CA:TRUE. After that, all certs signed by that key with the correct DN will be accepted by chrome without needing to add them independently.

    openssl req -new -x509 -extensions v3_req -days 8440 -config ca.conf -key rockstor.key -out rockstor.cert

    [req]
    distinguished_name=dn
    req_extensions=v3_req
    prompt = no
    
    [v3_req]
    basicConstraints=CA:TRUE,pathlen:0
    keyUsage = keyEncipherment, dataEncipherment
    extendedKeyUsage = serverAuth, clientAuth
    subjectAltName=@alt_names
    
    [alt_names]
    DNS.1 = ca.tdpowerskills.com
    
    [dn]
    C = US
    ST = LA
    L = Alexandria
    O = TDPS Certification Authority
    OU = LEARNOPS
    CN = ca.tdpowerskills.com
    

    openssl req -new -x509 -extensions v3_req -days 8440 -config config.conf -key rockstor.key -out rockstor.cert

    [req]
    distinguished_name=dn
    req_extensions=v3_req
    prompt = no
    
    [v3_req]
    basicConstraints=CA:FALSE
    keyUsage = keyEncipherment, dataEncipherment
    extendedKeyUsage = serverAuth, clientAuth
    subjectAltName=@alt_names
    issuerAltName=DNS:ca.tdpowerskills.com
    
    [alt_names]
    DNS.1 = big.tdps.app
    
    [dn]
    C = US
    ST = LA
    L = Alexandria
    O = TDPS Certification Authority
    OU = LEARNOPS
    CN = ca.tdpowerskills.com
    

    If that doesn't work:

    • chrome://restart to actually restart

    • Try to get more details on the error using firefox, it tends to explain errors better... while chrome will say, ERR_CERTIFICATE_INVALID, firefox will throw: MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY.

    • Remember that chrome now requires Subject Alternate Name and nearly ignores CN.

    For others:

    • certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n -i // For server sertificates

    • certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n -i for CA's https://blogs.oracle.com/meena/about-trust-flags-of-certificates-in-nss-database-that-can-be-modified-by-certutil

    • For Firefox, the UI adding an exception certificate does work and it will trust it once you do that.

    • Perhaps you have funky settings in /etc/pki/tls/openssl.cnf which get merged with your config.

    • perhaps you're no adding an extension to the config or command line, such as v3_req

    • Note, my method bypasses the need for a CSR by just signing the certificates with the authority key and adding details for the dev servers. CSR's allow more keys for actual security.

    • I tried everything, but chrome requires an authority with basicconstraints CA:true set. And server certificates must all be singed by a valid Authority... even if that's just another certificate that the signed themselves with CA:true.

提交回复
热议问题