Ensure STS headers are only honoured when they come from an HTTPS host

This commit is contained in:
Sam Gibson 2015-07-27 18:34:37 +12:00
parent c44579018a
commit 0d94ee917d

View file

@ -15,8 +15,7 @@ use std::collections::HashSet;
use file_loader;
use flate2::read::{DeflateDecoder, GzDecoder};
use hyper::client::Request;
use hyper::header::{AcceptEncoding, Accept, ContentLength, ContentType, Host, Location, qitem};
use hyper::header::{Quality, QualityItem};
use hyper::header::{AcceptEncoding, Accept, ContentLength, ContentType, Host, Location, qitem, Quality, QualityItem};
use hyper::header::StrictTransportSecurity;
use hyper::Error as HttpError;
use hyper::method::Method;
@ -299,6 +298,7 @@ reason: \"certificate verify failed\" }]))";
}
}
if url.scheme == "https" {
if let Some(header) = response.headers.get::<StrictTransportSecurity>() {
if let Some(host) = url.domain() {
info!("adding host {} to the strict transport security list", host);
@ -318,6 +318,7 @@ reason: \"certificate verify failed\" }]))";
).unwrap();
}
}
}
if response.status.class() == StatusClass::Redirection {