Hi,
apparently signature validation fails for valid signatures when @target-uri is used on HTTP/1.0 requests.
In HTTP/1.0 the host is provided in the separate HOST header instead of in the uri, see following longstanding issue in hyper: hyperium/hyper#1612
Just checking the request.uri() as in
|
DerivedComponentName::TargetUri => vec![req_or_res.uri()?.to_string()], |
does therefore not work for HTTP/1.0.
I have following horrendous hack in place to make it work with httpsig-hyper, but would be happy to add a PR if you have any idea on how to solve this cleanly within httpsig-hyper.
trait EffectiveUri {
fn reconstruct_effective_uri(self, scheme: &Scheme) -> Self ;
}
impl EffectiveUri for http::request::Parts {
fn reconstruct_effective_uri(mut self, scheme: &Scheme) -> Self {
if self.uri.host().is_none()
&& let Some(host) = self.headers.get(HOST)
{
let mut parts = self.uri.into_parts();
parts.scheme = Some(parts.scheme.unwrap_or(scheme.clone()));
let host = host.to_str().ok();
parts.authority = host.and_then(|host| Authority::from_str(host).ok());
let effective_uri: Uri = parts.try_into().unwrap();
self.uri = effective_uri;
}
self
}
}
Hi,
apparently signature validation fails for valid signatures when @target-uri is used on HTTP/1.0 requests.
In HTTP/1.0 the host is provided in the separate
HOSTheader instead of in the uri, see following longstanding issue in hyper: hyperium/hyper#1612Just checking the request.uri() as in
httpsig-rs/httpsig-hyper/src/hyper_http.rs
Line 891 in f8ab161
I have following horrendous hack in place to make it work with httpsig-hyper, but would be happy to add a PR if you have any idea on how to solve this cleanly within httpsig-hyper.