无法签署证书 LetsEncrypt

无法签署证书 LetsEncrypt

我最近通过 Nextcloud 设置了云。我已成功为我的域签署了证书https://mydomain.home.com(当然我的真实域是不同的)。这一切都很顺利。但现在我还想拥有“www.mydomain.home.com”的证书。但这行不通。

nc -z -v -w5 mydomain.home.com 80

报告:

DNS fwd/rev mismatch: mydomain.home.com != host-blabla
mydomain.home.com [255.255.255.255] 80 (http) open

所以用于验证的端口 80 应该没问题。这就是我的 nginx 配置的样子(站点可用/默认)

server {
listen 80;
server_name *.mydomain.home.com;
# enforce https
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name *.mydomain.home.com;

ssl_certificate /etc/letsencrypt/live/mydomain.home.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.home.com/privkey.pem;

# Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this
# topic first.
# add_header Strict-Transport-Security "max-age=15768000;
# includeSubDomains; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;

# Path to the root of your installation
root /var/www/nextcloud/;

我用了

certbot certonly --webroot -w /var/www/mydomain.home.com -d 
mydomain.home.com -d www.mydomain.home.com

如果我省略带有 www 的第二个域,它可以工作,但上面的命令会给出错误消息:

Failed authorization procedure. www.mydomain.home.com (http-01): 
urn:acme:error:connection :: The server could not connect to the client 
to verify the domain :: DNS problem: NXDOMAIN looking up A for 
www.mydomain.home.com

这是为什么?

另外当我使用

certbot renew --dry-run

我只得到:

Attempting to renew cert from 
/etc/letsencrypt/renewal/mydomain.home.com.conf produced an unexpected 
error: Failed authorization procedure. mydomain.home.com (http-01): 
urn:acme:error:connection :: The server could not connect to the client 
to verify the domain :: Fetching https://*.mydomain.home.com/.well-
known/acme-challenge/GwAAZEokTN1ByCuJUGP4t61mCeuTxIDKypd4DzhcfEg: Error 
getting validation data. Skipping.

答案1

我认为让加密需要通过http而不是访问您的服务器https。您需要对块.well-known中的目录进行例外处理http server

例如:

server {
    listen 80;
    server_name *.mydomain.home.com;

    location / {
        return 301 https://$server_name$request_uri;
    }
    location /.well-known/ {
        root /path/to/directory;
    }
}
server {
    listen 443 ssl;
    server_name *.mydomain.home.com;

    ssl_certificate ...;
    ssl_certificate_key ...;

    ...

    location /.well-known/ {
        root /path/to/directory;
    }
}

相关内容