Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Fix relative paths #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/acme/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl HandlerState {
.header(REPLAY_NONCE_HEADER, self.clone().nonce.unwrap())
.header(
"Link",
format!(r#"<{}>;rel="index""#, url.join("/")?.to_string()),
format!(r#"<{}>;rel="index""#, url.join("./")?.to_string()),
))
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/acme/handlers/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub(crate) async fn new_order(
}
}

let url = uri_to_url(appstate.clone().baseurl, req.uri().clone()).await?;
let url = appstate.clone().baseurl;

let order: Order =
crate::models::order::Order::find(o.id()?.unwrap(), appstate.db.clone())
Expand Down Expand Up @@ -186,7 +186,7 @@ pub(crate) async fn existing_order(
)
.await?;

let url = uri_to_url(appstate.clone().baseurl, req.uri().clone()).await?;
let url = appstate.clone().baseurl;
let h_order = serde_json::to_string(&o.clone().into_handler_order(url.clone())?)?;

return Ok((
Expand Down Expand Up @@ -333,7 +333,7 @@ pub(crate) async fn finalize_order(
Err(e) => return Err(ACMEValidationError::Other(e.to_string()).into()),
};

let url = uri_to_url(appstate.clone().baseurl, req.uri().clone()).await?;
let url = appstate.clone().baseurl;
let h_order = serde_json::to_string(&order.clone().into_handler_order(url.clone())?)?;

return Ok((
Expand Down Expand Up @@ -523,12 +523,9 @@ pub(crate) async fn post_authz(

let mut statuscode = StatusCode::CREATED;

let authz = Authorization::from_authorization_id(
auth_id,
uri_to_url(appstate.clone().baseurl, req.uri().clone()).await?,
&tx,
)
.await?;
let authz =
Authorization::from_authorization_id(auth_id, appstate.clone().baseurl, &tx)
.await?;
for chall in authz.clone().challenges {
if chall.status == OrderStatus::Valid {
statuscode = StatusCode::OK;
Expand Down Expand Up @@ -606,7 +603,10 @@ pub(crate) async fn post_challenge(
Some(
builder
.body(Body::from(serde_json::to_string(
&ChallengeAuthorization::from_challenge(&ch, ch.into_url(url))?,
&ChallengeAuthorization::from_challenge(
&ch,
ch.into_url(appstate.clone().baseurl),
)?,
)?))
.unwrap(),
),
Expand Down
10 changes: 6 additions & 4 deletions src/models/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ impl Order {
None
},
finalize: Some(
url.join(&format!("/order/{}/finalize", self.order_id))
url.join(&format!("./order/{}/finalize", self.order_id))
.unwrap(),
),
// FIXME this needs to be at a unique location, not related to the order id
certificate: Some(
url.join(&format!("/order/{}/certificate", self.order_id))
url.join(&format!("./order/{}/certificate", self.order_id))
.unwrap(),
),
};
Expand Down Expand Up @@ -444,7 +444,7 @@ impl Challenge {
}

pub(crate) fn into_url(&self, url: url::Url) -> url::Url {
url.join(&format!("/chall/{}", self.reference)).unwrap()
url.join(&format!("./chall/{}", self.reference)).unwrap()
}

fn new_from_row(result: &Row) -> Result<Self, LoadError> {
Expand Down Expand Up @@ -731,7 +731,9 @@ impl Authorization {
}

pub fn into_url(&self, baseurl: Url) -> Url {
baseurl.join(&format!("/authz/{}", self.reference)).unwrap()
baseurl
.join(&format!("./authz/{}", self.reference))
.unwrap()
}
}

Expand Down