Skip to content

Commit 8aea602

Browse files
committed
ACME: check that the account status is valid.
1 parent 6d1a12c commit 8aea602

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/acme.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use ngx::collections::Vec;
1818
use ngx::ngx_log_debug;
1919
use openssl::pkey::{PKey, PKeyRef, Private};
2020
use openssl::x509::{self, extension as x509_ext, X509Req};
21-
use types::ProblemCategory;
21+
use types::{AccountStatus, ProblemCategory};
2222

2323
use self::account_key::{AccountKey, AccountKeyError};
2424
use self::types::{AuthorizationStatus, ChallengeKind, ChallengeStatus, OrderStatus};
@@ -287,6 +287,11 @@ where
287287

288288
let res = self.post(&self.directory.new_account, payload).await?;
289289

290+
let account: types::Account = deserialize_body(res.body())?;
291+
if !matches!(account.status, AccountStatus::Valid) {
292+
return Err(NewAccountError::Status(account.status));
293+
}
294+
290295
let key_id: &str =
291296
try_get_header(res.headers(), http::header::LOCATION).ok_or(NewAccountError::Url)?;
292297

src/acme/error.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use ngx::allocator::{unsize_box, Box};
99
use thiserror::Error;
1010

1111
use super::solvers::SolverError;
12-
use super::types::{Problem, ProblemCategory};
12+
use super::types::{AccountStatus, Problem, ProblemCategory};
1313
use crate::net::http::HttpClientError;
1414

1515
#[derive(Debug, Error)]
@@ -26,6 +26,9 @@ pub enum NewAccountError {
2626
#[error("account request failed ({0})")]
2727
Request(RequestError),
2828

29+
#[error("unexpected account status {0:?}")]
30+
Status(AccountStatus),
31+
2932
#[error("no account URL in response")]
3033
Url,
3134
}
@@ -47,6 +50,7 @@ impl NewAccountError {
4750
err.category(),
4851
ProblemCategory::Account | ProblemCategory::Malformed
4952
),
53+
Self::Status(_) => true,
5054
_ => false,
5155
}
5256
}

0 commit comments

Comments
 (0)