Skip to content

AuthorizationHandle::challenge lifetime issueΒ #147

@beviu

Description

@beviu

Hi,

The signature for AuthorizationHandle::challenge is:

pub fn challenge(&'a mut self, r#type: ChallengeType) -> Option<ChallengeHandle<'a>> {

I am trying to write code that reads from the authorization after I'm done with the challenge:

use instant_acme::{Authorization, ChallengeType};

fn main() {
    let authorization: Authorization = todo!();
    let Some(challenge) = authorization.challenge(ChallengeType::Dns01) else {
        eprintln!(
            "Missing DNS-01 challenge for authorization {:?}",
            authorization.identifier().identifier
        );
        return;
    };
    println!("Challenge identifier: {:?}", challenge.identifier());
}

This code does not compile. I think it is because, in challenge, the lifetime of the mutable reference to the AuthorizationHandle<'a> is forced to be the maximum lifetime 'a.

Would it be possible to use a different lifetime 'a: 'b instead of 'a here? I tested the following patch and it makes the code above work:

-    pub fn challenge(&'a mut self, r#type: ChallengeType) -> Option<ChallengeHandle<'a>> {
+    pub fn challenge(&mut self, r#type: ChallengeType) -> Option<ChallengeHandle<'_>> {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions