如何在Ubuntu上'信任'自签名的.dev证书

时间:2019-04-03 13:38:03

标签: ubuntu ssl openssl ssl-certificate

当我们过渡到使用购买的.dev域进行本地开发时,我正在使用以下代码生成证书:

openssl req -x509 -out domain.dev.crt -keyout domain.dev.key \
  -newkey rsa:2048 -nodes -sha256 \
  -days 3650 \
  -subj '/C=UK/O=Vizibl/CN=*.domain.dev' -extensions EXT -config <( \
   printf "[dn]\nCN=*.domain.dev\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:*.domain.dev\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

将证书添加到“钥匙串访问”中后,该证书在Mac OSX上可以正常工作,但是在ubuntu上,使用任何浏览器都遇到问题。

我尝试将证书添加到我的ca-certificates中,并确保它出现在我的certificates.crt中。

在chrome中,当访问指向URL的本地主机域(例如microservice1.domain.dev)时,我遇到了NET::ERR_CERT_INVALID。我还确认了,如果我尝试指定特定的子域而不是根证书,那么这将无效。

1 个答案:

答案 0 :(得分:0)

openssl genrsa -out domain.dev.key 2048
openssl req -new -key domain.dev.key -out *.domain.dev.csr

openssl x509 -req -in *.domain.dev.csr -CA domainCA.crt -CAkey domainCA.key -CAcreateserial \
-out domain.dev.crt -days 1825 -sha256 -extfile *.domain.dev.ext

sudo cp domain.dev.crt domainCA.crt  /usr/share/ca-certificates
sudo update-ca-certificate

此过程在我生成CA crt和密钥后起作用。

相关问题