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

Update dependencies and fix OCSP stapling #6

Merged
merged 3 commits into from
May 17, 2022

Conversation

cedricdubois
Copy link

Hi

This PR fixes two things:

  1. It updates dependencies for golang.org/x/crypto so the correct certificate chain is included in the LE certs (older versions included the expired certificates)
  2. Fixes OCSP stapling which failed because the wrong certificate was selected as issuer certificate.

Tested these changes and works as expected.

Please let me know if this needs changes.

Thanks!

Kind regards,
Cedric

Cedric Dubois added 2 commits May 12, 2022 16:24
Using the last cert in the chain caused "unauthorized" responses
@jxskiss
Copy link
Owner

jxskiss commented May 14, 2022

Thanks much for you contribution! I will look at it soon.

server/ocsp.go Outdated
@@ -154,7 +154,7 @@ func (m *ocspManager) touchState(keyName string) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

issuer, err := x509.ParseCertificate(cert.Certificate[len(cert.Certificate)-1])
issuer, err := x509.ParseCertificate(cert.Certificate[len(cert.Certificate)-2])
Copy link
Owner

Choose a reason for hiding this comment

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

cert.Certificate[length-1] shoule be the certificate of "Let's Encrypt", and cert.Certificate[length-2] will be the certificate of "ISRG Root X1", I am not sure why this should be changed to cert.Certificate[length-2] ?

Copy link
Owner

Choose a reason for hiding this comment

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

Well, I can confirm the "unauthorized" responses in log, but have no idea why it happens

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, I made a mistake, the certificate of "Let's Encrypt" should be cert.Certificate[1], this line should be
issuer, err := x509.ParseCertificate(cert.Certificate[1]), how about your thought?

Copy link
Author

Choose a reason for hiding this comment

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

Indeed, the second cert in the chain is what we need. I've updated the code to directly specify cert.Certificate[1] here.

Thanks for the review!

@jxskiss jxskiss merged commit 4949608 into jxskiss:master May 17, 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.

2 participants