Skip to content

Conversation

@moratori
Copy link
Contributor

@moratori moratori commented May 3, 2022

Address the issue #83
Fixed to add Retry-After header when responding to requests for Order and Authorization objects.

Although it is a static, The value of Retry-After is defined in the configuration file.
I would appreciate it if you could review this PR.

@moratori
Copy link
Contributor Author

moratori commented May 5, 2022

Thank you very much for your feedback.
Maybe I think that I have fixed the above issues.
Could you please review it once again.

Copy link
Contributor

@aarongable aarongable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small comments, otherwise looks good to me!

wfe/wfe.go Outdated
Comment on lines 2469 to 2472
if (second > 0){
if (rand.Intn(2) == 0){
response.Header().Add("Retry-After", strconv.Itoa(second))
}else{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you run gofmt to fix the spacing around these curly braces.

wfe/wfe.go Outdated
Comment on lines 2094 to 2105
// Check for the existence of a challenge which state is processing
processingChallenge := false
for _, c := range authz.Challenges {
if (c.Status == acme.StatusProcessing) {
processingChallenge = true
break
}
}
// if exist, then add header
if processingChallenge {
addRetryAfterHeader(response, wfe.retryAfterAuthz)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: inline the call to add the header, so you don't need the extra variable:

Suggested change
// Check for the existence of a challenge which state is processing
processingChallenge := false
for _, c := range authz.Challenges {
if (c.Status == acme.StatusProcessing) {
processingChallenge = true
break
}
}
// if exist, then add header
if processingChallenge {
addRetryAfterHeader(response, wfe.retryAfterAuthz)
}
// Check for the existence of a challenge which state is processing, and add the
// Retry-After header if there is one.
processingChallenge := false
for _, c := range authz.Challenges {
if (c.Status == acme.StatusProcessing) {
addRetryAfterHeader(resonse, wfe.retryAfterAuthz)
break
}
}

@moratori
Copy link
Contributor Author

moratori commented May 6, 2022

I finished editing it!
If you have any other comments, please let me know.

aarongable
aarongable previously approved these changes May 6, 2022
wfe/wfe.go Outdated
// Check for the existence of a challenge which state is processing, and add the
// Retry-After header if there is one.
for _, c := range authz.Challenges {
if c.Status == acme.StatusProcessing {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in this comment, the processing state for challenges is not currently implemented in Pebble.

Consequently, the Retry-After header is never sent for challenges.

I think we'd need to set the state to processing right as the challenge is queued up for validation in wfe.updateChallenge. Do we want to do this in a separate PR or here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexzorin
There was an error in my understanding. My apologies.
I now understand that processing status is not currently used for challenge in pebble.
Regarding the unused processing, I felt that perhaps it would be appropriate to proceed with implementation in another PR.

wfe/wfe.go Outdated
// Check for the existence of a challenge which state is processing, and add the
// Retry-After header if there is one.
for _, c := range authz.Challenges {
if c.Status == acme.StatusProcessing {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's likely that we need to do a c.RLock() and c.RUnlock() around the access to c.Status, or it may be a race.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexzorin
Thank you for your comment. I will attempt to fix this problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem was fixed by commit 6f709f9

@moratori
Copy link
Contributor Author

@alexzorin
@aarongable
I'm sorry to bother you again, I would be grateful if you could review it.
Fixed to acquire RLock before reading status of challenge.

@alexzorin
Copy link
Contributor

Sorry for disappearing. I'd still like to fix #382 soon, to enable this PR.

@moratori
Copy link
Contributor Author

Thank you for implementing it!

jsha pushed a commit that referenced this pull request Jun 27, 2022
For #380 (comment). 

Keeping track of when a challenge is in the `processing` state means we will be able
to then include a `Retry-After` response header for authorizations, as described in:

>    To check on the status of an authorization, the client sends a POST-
   as-GET request to the authorization URL, and the server responds with
   the current authorization object.  In responding to poll requests
   while the validation is still in progress, the server MUST return a
   200 (OK) response and MAY include a Retry-After header field to
   suggest a polling interval to the client.

One extra side effect here is that clients will no longer be able to cause Pebble to
queue up a `pending` challenge multiple times for processing by a VA. This seems
like a good thing anyway.
@moratori
Copy link
Contributor Author

moratori commented Jun 29, 2022

@alexzorin
It seems that the PR #382 was merged successfully.
I would appreciate it if you review this PR once again.

Copy link
Contributor

@alexzorin alexzorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM and appears to work well, thank you!

The PR will still require another review from @aarongable to merge.

@aarongable aarongable merged commit 6538ad0 into letsencrypt:main Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants