AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 798217
Accepted
Chazy Chaz
Chazy Chaz
Asked: 2016-08-22 12:35:12 +0800 CST2016-08-22 12:35:12 +0800 CST 2016-08-22 12:35:12 +0800 CST

https://domain.com ssl 错误,除非添加异常,否则它不会重定向到 www

  • 772

我使用 certbot 为我的域创建了一个让我们加密证书。我确保包含 www 和一些(需要的)子域,因此证书应该对非 www 和 www 有效:

domain.com www.domain.com sub1.domain.com ...

但事实并非如此,如果我尝试访问https://domain.com会引发 ssl 错误。

在证书查看器中(通过 www 访问时)我可以看到 Common Name (CA) domain.com。证书主题替代名称包含非 www 和 www...

所以我不明白为什么它会给出这个错误:

domain.com uses an invalid security certificate.
The certificate is not trusted because it is self-signed.
Error code: SEC_ERROR_UNKNOWN_ISSUER

我确实生成了一个自签名证书,但是对于默认的虚拟主机块(httpd-ssl.conf 中的那个),其他块正在使用让我们加密证书。

我还确保删除了 Firefox 缓存。

我确实添加了一个异常,现在每次我写https://domain.com时它都会重定向到https://www.domain.com。

我使用的是 Apache 2.4.23,我的虚拟主机配置如下:

<VirtualHosts *:80>
    Servername domain.com
    Redirect permanent / https://www.domain.com/
</VirtualHosts>

<VirtualHost *:443>
    ServerName domain.com:443
    Redirect permanent / https://www.domain.com:443/
</VirtualHost>

<VirtualHost *:PORT> # 80 and 443
    ServerAdmin [email protected]
    DocumentRoot "/srv/http/domain.com/www"
    ServerName www.domain.com:443
    Protocols h2 h2c

    <Directory "/srv/http/domain.com/www">
        Require all granted

        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^index\.php$ - [L]
            RewriteRule . index.php [L]
        </IfModule>
    </Directory>

    <IfModule dir_module>
        DirectoryIndex index.php
    </IfModule>

    SSLEngine on
    SSLCertificateFile "/etc/letsencrypt/live/domain.com/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/domain.com/privkey.pem"
    Header always set Strict-Transport-Security "max-age=15768000"
    ErrorLog "/var/log/httpd/domain.com-ssl_error_log"
    CustomLog "/var/log/httpd/domain.com-ssl_access_log" common
    LogLevel debug
</VirtualHost>
virtualhost ssl https apache-2.4 tls
  • 1 1 个回答
  • 1034 Views

1 个回答

  • Voted
  1. Best Answer
    Michael Hampton
    2016-08-22T14:08:12+08:002016-08-22T14:08:12+08:00

    您没有为对 example.com 的请求提供 Let's Encrypt 证书。

    <VirtualHost *:443>
        ServerName domain.com:443
        Redirect permanent / https://www.domain.com:443/
    </VirtualHost>
    

    缺少所有相关的 SSL 指令。

        SSLEngine on
        SSLCertificateFile "/etc/letsencrypt/live/domain.com/fullchain.pem"
        SSLCertificateKeyFile "/etc/letsencrypt/live/domain.com/privkey.pem"
        Header always set Strict-Transport-Security "max-age=15768000"
    
    • 5

相关问题

  • 阿帕奇虚拟主机

  • Apache:对多个虚拟主机使用相同的目录指令

  • Apache 中的动态虚拟主机

  • VirtualHost / NameVirtualHost 背后的逻辑是什么

  • 如何设置 Jetty 6 和 Jboss 4.0.5 虚拟主机?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve