0
我在两台主机上部署了相同的(Django)网站;一个使用SSL和一个snakeoil证书,另一个只使用HTTP。我正在尝试使用wget
编写脚本。以下脚本适用于HTTP站点,但不适用于HTTPS。wget cookies登录脚本:同一网站,HTTP脚本有效,HTTPS不会
请注意它的Django站点。登录需要2个请求。第一个请求获取登录表单的CSRF令牌,第二个职位登录名气后面 - 随着CSRF令牌:
rm ${COOKIE_FILE}
TOKEN=`wget ${LOGIN_URL} -O- --save-cookies ${COOKIE_FILE} --keep-session-cookies \
--server-response --no-check-certificate \
| grep csrfmiddlewaretoken | sed -r 's/.*value="(.*)".*/\1/'`
POST="csrfmiddlewaretoken=${TOKEN}&username=${USERNAME}&password=${PASSWORD}"
wget ${LOGIN_URL} -O- --load-cookies ${COOKIE_FILE} --save-cookies ${COOKIE_FILE} \
--keep-session-cookies --no-check-certificate --server-response \
--post-data "$POST" >/dev/null
在SSL网站,我得到这样的输出:
--2016-09-13 01:20:38-- https://nowhere.com/accounts/login/
Resolving nowhere.com (nowhere.com)... 10.1.1.123
Connecting to nowhere.com (nowhere.com)|10.1.1.123|:443... connected.
WARNING: The certificate of ‘nowhere.com’ is not trusted.
WARNING: The certificate of ‘nowhere.com’ hasn't got a known issuer.
The certificate's owner does not match hostname ‘nowhere.com’
HTTP request sent, awaiting response...
HTTP/1.1 403 FORBIDDEN
Date: Mon, 12 Sep 2016 15:20:58 GMT
X-Frame-Options: SAMEORIGIN
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
2016-09-13 01:20:41 ERROR 403: FORBIDDEN.
我已经验证我可以通过浏览器以相同的凭据登录到HTTPS站点。我怀疑它与SSL有关?有任何想法吗?