HTTPS学习笔记

上次发现一个免费的SSL证书,而且Google浏览器显示绿锁图标,于是忍不住搞了一下HTTPS的东西。

如果网页地址使用了HTTPS,那么静态资源也要使用,否者提示错误:Mixed Content: The page at 'https://www.acgist.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://static.acgist.com/resources/css/style.css'. This request has been blocked; the content must be served over HTTPS.

不过图片img不会提示错误,但是绿锁会消失。

还有最好静态资源不要加http:或者https:,而是直接使用//开头,例如:

<link href="//static.acgist.com/resources/css/style.css" rel="stylesheet" type="text/css" />

这样浏览器会自动判断是HTTP还是HTTPS