Skip to main content

load_or_register_account

Function load_or_register_account 

Source
pub async fn load_or_register_account(
    store: &CertStore,
    directory_url: &str,
    contact: &[&str],
    http: Box<dyn HttpClient>,
) -> Result<Account, BootstrapError>
Expand description

The ACME account directory_url should be reached through: the one saved in store if it was registered there, and a freshly registered one otherwise, saved over it.

An account belongs to the directory that registered it. It can place orders there and nowhere else, and the CAA record naming it authorises issuance there and nowhere else — so a deployment that switches directories (staging to production, the switch that makes its certificates publicly trusted) needs an account at the new one before it can order anything. Credentials that record no directory at all are replaced too: one round trip to register an account is the cheaper half of that guess.

Taking the [instant_acme::HttpClient] as an argument is the same seam CertificateManager::bootstrap_with_account is: CertificateManager::bootstrap passes a ReqwestAcmeClient against a real Let’s Encrypt directory, and a test passes a client answering as an in-process fake one.