Skip to content

Commit d1f7fae

Browse files
committed
feat: Add ACME account status verification and use verified account credentials for certificate issuance.
1 parent 1cf6853 commit d1f7fae

File tree

1 file changed

+18
-1
lines changed
  • landscape/src/config_service/cert

1 file changed

+18
-1
lines changed

landscape/src/config_service/cert/order.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use instant_acme::{
66
Account, ChallengeType as AcmeChallengeType, Identifier, NewOrder, OrderStatus, RetryPolicy,
77
RevocationRequest,
88
};
9+
use landscape_common::cert::account::AccountStatus;
910
use landscape_common::cert::order::{CertConfig, CertParsedInfo, CertStatus, CertType};
1011
use landscape_common::cert::CertError;
1112
use landscape_common::service::controller::ConfigController;
@@ -318,7 +319,23 @@ impl CertService {
318319
.await
319320
.ok_or(CertError::AccountNotFound(acme.account_id))?;
320321

321-
let credentials_json = account_config
322+
if !matches!(account_config.status, AccountStatus::Registered) {
323+
return Err(CertError::InvalidStatusTransition(format!(
324+
"ACME account is not registered: {:?}",
325+
account_config.status
326+
)));
327+
}
328+
329+
let verified_account = self.account_service.verify_account(acme.account_id).await?;
330+
331+
if !matches!(verified_account.status, AccountStatus::Registered) {
332+
return Err(CertError::IssuanceFailed(format!(
333+
"ACME account verification failed, current status: {:?}",
334+
verified_account.status
335+
)));
336+
}
337+
338+
let credentials_json = verified_account
322339
.account_private_key
323340
.as_ref()
324341
.ok_or_else(|| CertError::IssuanceFailed("Account has no credentials".to_string()))?;

0 commit comments

Comments
 (0)