Skip to main content

acme/api/
challenge.rs

1use serde::{Deserialize, Serialize};
2
3use crate::api;
4
5/// The status of an [`api::Authorization`].
6///
7/// See [RFC 8555 §7.1.6].
8///
9/// [RFC 8555 §7.1.6]: https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.6
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(rename_all = "lowercase")]
12pub enum ChallengeStatus {
13    Pending,
14    Processing,
15    Valid,
16    Invalid,
17}
18
19/// An ACME challenge object.
20///
21/// Represents a server's offer to validate a client's possession of an identifier in a specific
22/// way.
23///
24/// See [RFC 8555 §7.1.5].
25///
26/// # Example JSON
27///
28/// ```json
29/// {
30///   "type": "http-01",
31///   "status": "pending",
32///   "url": "https://acme-staging-v02.api.letsencrypt.org/acme/challenge/YTqpYUthlVfwBncUufE8IRA2TkzZkN4eYWWLMSRqcSs/216789597",
33///   "token": "MUi-gqeOJdRkSb_YR2eaMxQBqf6al8dgt_dOttSWb0w"
34/// }
35/// ```
36///
37/// [RFC 8555 §7.1.5]: https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.5
38#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
39pub struct Challenge {
40    /// Type of challenge encoded in the object.
41    #[serde(rename = "type")]
42    pub _type: String,
43
44    /// URL to which a response can be posted.
45    pub url: String,
46
47    /// Status of this challenge.
48    pub status: ChallengeStatus,
49
50    /// Time at which the server validated this challenge.
51    ///
52    /// Uses RFC 3339 format.
53    pub validated: Option<String>,
54
55    /// Error that occurred while the server was validating the challenge, if any.
56    pub error: Option<api::Problem>,
57
58    pub token: String,
59}