1
1
use std:: sync:: Arc ;
2
+ #[ cfg( feature = "time" ) ]
3
+ use std:: time:: { Duration , SystemTime } ;
2
4
3
5
use base64:: prelude:: { BASE64_URL_SAFE_NO_PAD , Engine } ;
4
6
use http:: header:: LOCATION ;
@@ -12,7 +14,7 @@ use serde::{Deserialize, Serialize};
12
14
13
15
#[ cfg( feature = "hyper-rustls" ) ]
14
16
use crate :: DefaultClient ;
15
- use crate :: order:: Order ;
17
+ use crate :: order:: { Order , retry_after } ;
16
18
use crate :: types:: {
17
19
AccountCredentials , AuthorizationStatus , Empty , Header , JoseJson , Jwk , KeyOrKeyId , NewAccount ,
18
20
NewAccountPayload , NewOrder , OrderState , Problem , ProfileMeta , RevocationRequest , Signer ,
@@ -143,16 +145,18 @@ impl Account {
143
145
/// uniformly random point between the window start/end should be selected and used to
144
146
/// schedule a renewal in the future.
145
147
///
148
+ /// The `Duration` is a hint from the ACME server when to again fetch the renewal window.
149
+ /// See <https://www.rfc-editor.org/rfc/rfc9773.html#section-4.3.2> for details.
150
+ ///
146
151
/// This is only supported by some ACME servers. If the server does not support this feature,
147
152
/// this method will return `Error::Unsupported`.
148
153
///
149
- /// See <https://www.rfc-editor.org/rfc/rfc9773.html#section-4.2-4> for more
150
- /// information.
154
+ /// See <https://www.rfc-editor.org/rfc/rfc9773.html#section-4.2-4> for more information.
151
155
#[ cfg( feature = "time" ) ]
152
156
pub async fn renewal_info (
153
157
& self ,
154
158
certificate_id : & CertificateIdentifier < ' _ > ,
155
- ) -> Result < RenewalInfo , Error > {
159
+ ) -> Result < ( RenewalInfo , Duration ) , Error > {
156
160
let renewal_info_url = match self . inner . client . directory . renewal_info . as_deref ( ) {
157
161
Some ( url) => url,
158
162
None => return Err ( Error :: Unsupported ( "ACME renewal information (ARI)" ) ) ,
@@ -166,7 +170,16 @@ impl Account {
166
170
. body ( Full :: default ( ) ) ?;
167
171
168
172
let rsp = self . inner . client . http . request ( request) . await ?;
169
- Problem :: check :: < RenewalInfo > ( rsp) . await
173
+
174
+ let Some ( retry_after) = retry_after ( & rsp) else {
175
+ return Err ( Error :: Str ( "missing Retry-After header" ) ) ;
176
+ } ;
177
+
178
+ let delay = retry_after
179
+ . duration_since ( SystemTime :: now ( ) )
180
+ . unwrap_or ( Duration :: ZERO ) ;
181
+
182
+ Ok ( ( Problem :: check :: < RenewalInfo > ( rsp) . await ?, delay) )
170
183
}
171
184
172
185
/// Update the account's authentication key
0 commit comments