Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate OCSP response ProducedAt. #515

Merged
merged 3 commits into from
Mar 29, 2021
Merged

Conversation

twifkak
Copy link
Member

@twifkak twifkak commented Mar 26, 2021

Don't accept an OCSP response if its ProducedAt is outside the leaf cert's
NotBefore/NotAfter validity window.

Fixes #514.

Don't accept an OCSP response if its ProducedAt is outside the leaf cert's
NotBefore/NotAfter validity window.
@twifkak twifkak requested a review from banaag March 26, 2021 02:14
@twifkak
Copy link
Member Author

twifkak commented Mar 26, 2021

To make it easier to review, you may want to look at this commit separately from the vendor update.

@@ -429,9 +429,9 @@ func (this *CertCache) readOCSP(allowRetries bool) ([]byte, time.Time, error) {

// Print # of retries, wait for specified time and returned updated wait time.
func waitForSpecifiedTime(waitTimeInMinutes int, numRetries int) int {
log.Printf("Retrying OCSP server: retry #%d\n", numRetries)
log.Printf("Retrying OCSP server: retry #%d", numRetries)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you remove the \n on purpose? Did you mean to change it to Println then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the \n is redundant. I saw this done on webpkg. It's a difference between fmt and log: https://golang.org/pkg/log/#pkg-overview:~:text=Every%20log%20message%20is%20output%20on,newline%2C%20the%20logger%20will%20add%20one.

var err error
this.fakeOCSP, err = FakeOCSPResponse(this.fakeClock.Now())
this.fakeOCSP, err = FakeOCSPResponse(now, now.Add(1*time.Minute))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a comment here as to why a minute was added?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Decided to extract it into the FakeOCSPResponse function so there was only one place to document it.

@twifkak twifkak merged commit 8da047b into ampproject:master Mar 29, 2021
@twifkak twifkak deleted the produced_at branch March 29, 2021 19:44
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.

2 participants