Make DirectoryUrls::revoke_cert optional

This commit is contained in:
Dirkjan Ochtman 2024-02-05 13:50:20 +01:00
parent e7fcd3c3b9
commit 601330bc82
2 changed files with 14 additions and 5 deletions

View File

@ -366,10 +366,16 @@ impl Account {
/// Revokes a previously issued certificate /// Revokes a previously issued certificate
pub async fn revoke<'a>(&'a self, payload: &RevocationRequest<'a>) -> Result<(), Error> { pub async fn revoke<'a>(&'a self, payload: &RevocationRequest<'a>) -> Result<(), Error> {
let rsp = self let revoke_url = match self.inner.client.urls.revoke_cert.as_deref() {
.inner Some(url) => url,
.post(Some(payload), None, &self.inner.client.urls.revoke_cert) // This happens because the current account credentials were deserialized from an
.await?; // older version which only serialized a subset of the directory URLs. You should
// make sure the account credentials include a `directory` field containing a
// string with the server's directory URL.
None => return Err("no revokeCert URL found".into()),
};
let rsp = self.inner.post(Some(payload), None, revoke_url).await?;
// The body is empty if the request was successful // The body is empty if the request was successful
let _ = Problem::from_response(rsp).await?; let _ = Problem::from_response(rsp).await?;
Ok(()) Ok(())

View File

@ -353,7 +353,10 @@ pub(crate) struct DirectoryUrls {
pub(crate) new_nonce: String, pub(crate) new_nonce: String,
pub(crate) new_account: String, pub(crate) new_account: String,
pub(crate) new_order: String, pub(crate) new_order: String,
pub(crate) revoke_cert: String, // The fields below were added later and old `AccountCredentials` may not have it.
// Newer deserialized account credentials grab a fresh set of `DirectoryUrls` on
// deserialization, so they should be fine. Newer fields should be optional, too.
pub(crate) revoke_cert: Option<String>,
} }
#[derive(Serialize)] #[derive(Serialize)]