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

Panic when no issuer is selected #204

Closed
Webbmekanikern opened this issue Sep 1, 2022 · 5 comments
Closed

Panic when no issuer is selected #204

Webbmekanikern opened this issue Sep 1, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@Webbmekanikern
Copy link

What version of the package are you using?

v0.17.0

What are you trying to do?

Issue a certificate.

What steps did you take?

Exceed the Let's Encrypt limit of max certificates per domain and hour.

What did you expect to happen, and what actually happened instead?

I expected a clear error message that no issuer could be selected, possibly due to limits of the issuers. Instead I got a panic due to nil pointer dereference:

$: panic: runtime error: invalid memory address or nil pointer dereference
$: [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x8d696d]
$: goroutine 1 [running]:
$: github.com/caddyserver/certmagic.(*Config).obtainCert.func2({0xc66ba0, 0xc00003a060})
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/config.go:579 +0x66d
$: github.com/caddyserver/certmagic.(*Config).obtainCert(0xc000156a50, {0xc66ba0, 0xc00003a060}, {0xc00003ed8b, 0x1f}, 0x1)
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/config.go:614 +0x5cc
$: github.com/caddyserver/certmagic.(*Config).ObtainCertSync(...)
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/config.go:446
$: github.com/caddyserver/certmagic.(*Config).manageOne.func1()
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/config.go:351 +0x8e
$: github.com/caddyserver/certmagic.(*Config).manageOne(0xc000156a50, {0xc66ba0?, 0xc00003a060}, {0xc00003ed8b, 0x1f}, 0x0)
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/config.go:378 +0x307
$: github.com/caddyserver/certmagic.(*Config).manageAll(0xc000156a50, {0xc66ba0?, 0xc00003a060?}, {0xc000681100?, 0x1, 0x0?}, 0x68?)
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/config.go:329 +0x110
$: github.com/caddyserver/certmagic.(*Config).ManageSync(...)
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/config.go:268
$: github.com/caddyserver/certmagic.HTTPS({0xc000681100, 0x1, 0x1}, {0xc5fb60?, 0xc000565200?})
$:         /go/pkg/mod/github.com/caddyserver/certmagic@v0.17.0/certmagic.go:78 +0xe7

How do you think this should be fixed?

Add a check whether issuerUsed still is nil after the loop: https://github.com/caddyserver/certmagic/blob/master/config.go#L541

@mholt mholt closed this as completed in 2e22c6f Sep 1, 2022
@mholt
Copy link
Member

mholt commented Sep 1, 2022

Ah, thanks! Fixed in 2e22c6f

@mholt mholt added the bug Something isn't working label Sep 1, 2022
@Webbmekanikern
Copy link
Author

Webbmekanikern commented Sep 1, 2022

That was incredibly fast - thanks @mholt!

And sorry for not making a pull request, I were a bit short of time here.

@mholt
Copy link
Member

mholt commented Sep 1, 2022

No worries. Does the patch work for you then? Just a sanity check 😅

@Webbmekanikern
Copy link
Author

Yup, works:

$: 2022/09/01 17:56:47 X.X.X: obtaining certificate: [X.X.X] Obtain: [X.X.X] creating new order: attempt 1: https://acme-v02.api.letsencrypt.org/acme/new-order: HTTP 429 urn:ietf:params:acme:error:rateLimited - Error creating new order :: too many certificates (5) already issued for this exact set of domains in the last 168 hours: X.X.X, retry after 2022-09-03T00:29:08Z: see https://letsencrypt.org/docs/duplicate-certificate-limit/ (ca=https://acme-v02.api.letsencrypt.org/directory)

Note to self: Don't make excuses for not using the staging CA.

@mholt
Copy link
Member

mholt commented Sep 1, 2022

Thanks! Will tag a release then.

ankon added a commit to ankon/certmagic that referenced this issue Sep 23, 2022
This merges caddyserver#204 to a similar place in config.go.
ankon added a commit to ankon/certmagic that referenced this issue Sep 23, 2022
This merges caddyserver#204 to a similar place in config.go.
mholt pushed a commit that referenced this issue Sep 23, 2022
This merges #204 to a similar place in config.go.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants