【发布时间】:2020-03-25 13:57:59
【问题描述】:
我创建了一个网站,尝试通过 httpd.conf 添加 HSTS 安全标头
<IfModule mod_headers.c>
Header always set Strict-Transport-Security 'max-age=4000; includeSubDomains'
</IfModule>
添加上面的代码,可以看到在我的 HTTPS 响应头上添加的 Strict-Transport-Security 头
host> curl -v https://172.21.218.67 --insecure
* About to connect() to 172.21.218.67 port 443 (#0)
* Trying 172.21.218.67... connected
* Connected to 172.21.218.67 (172.21.218.67) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* warning: ignoring value of ssl.verifyhost
* skipping SSL peer certificate verification
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
* subject: ****************************************
* start date: Oct 21 06:42:49 2019 GMT
* expire date: Nov 20 06:42:49 2019 GMT
* common name: Insights
* issuer: *****************************************
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 172.21.218.67
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 21 Oct 2019 10:50:54 GMT
< Server: Apache
< Strict-Transport-Security: max-age=4000; includeSubDomains
< Last-Modified: Mon, 21 Oct 2019 08:58:58 GMT
< ETag: "8f3-59567e4f07362"
< Accept-Ranges: bytes
< Content-Length: 2291
< Content-Type: text/html
但这确实会通过浏览器对我的网站产生影响。 (如果用户尝试通过 HTTP 访问我的网站,浏览器不会重定向到 HTTPS)。
我什至看不到我的网站在 chrome 的 HSTS 清单中列出
chrome://net-internals/#hsts
是否需要添加任何其他配置才能使其正常工作?
【问题讨论】:
-
我注意到您在
curl命令上使用了--insecure,可能是因为您没有在此测试系统上使用受信任的证书。浏览器可能拒绝接受不受信任站点的 HSTS 标头。 -
谢谢...将努力使我的网站成为可信赖的来源
-
你的意思是证书需要由有效的CA颁发吗?虽然我尝试使用自签名证书“证书有效”,但仍然显示“不安全”连接不起作用。
标签: google-chrome security httpd.conf hsts