-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix(client): race in cert renewal #42
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this refactor ensures unique cache per instance is initialized, and the global default cert management in certmagic is not triggered. circular dependency is solved in alrernative way: 1. recursive call for newCertmagicConfig is removed and replaced by simpler configGetter 2. TLSConfig() ensures correct GetCertificate() is used
lidel
force-pushed
the
fix/cert-renewal-race
branch
from
January 21, 2025 19:36
9b096a7
to
60f66f8
Compare
basic test that confirms cert renewal works as expected when expiration event is triggered
Smoke-tests here and in Kubo passed, merging to include in Kubo 0.33.0-rc2 |
lidel
added a commit
to ipfs/kubo
that referenced
this pull request
Jan 22, 2025
updates to p2p-forge/client with fix from ipshipyard/p2p-forge#42 we also add AutoTLS.ShortAddrs flag and enable it by default to benefit from shorter addrs discusses in ipshipyard/p2p-forge#40
lidel
added a commit
to ipfs/kubo
that referenced
this pull request
Jan 22, 2025
* fix(autotls): renewal and AutoTLS.ShortAddrs updates to p2p-forge/client with fix from ipshipyard/p2p-forge#42 we also add AutoTLS.ShortAddrs flag and enable it by default to benefit from shorter addrs discusses in ipshipyard/p2p-forge#40 * test: fix flaky NewRandPort reducing chance of bind: address already in use
lidel
added a commit
to ipfs/kubo
that referenced
this pull request
Jan 22, 2025
* fix(autotls): renewal and AutoTLS.ShortAddrs updates to p2p-forge/client with fix from ipshipyard/p2p-forge#42 we also add AutoTLS.ShortAddrs flag and enable it by default to benefit from shorter addrs discusses in ipshipyard/p2p-forge#40 * test: fix flaky NewRandPort reducing chance of bind: address already in use (cherry picked from commit 256a739)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #28.
Previously, we had global
defaultCertCache
and relied onGetConfigForCert
recursively callingnewCertmagicConfig
, which was likely a surface for racy bug from #28 where p2p-forge instance was not fully wired up yetUsing custom things with certmagic is pretty awkward due to circular dependency that shows only when custom config, cache, storage are issues are used.
In this PR, the circular dependency is solved in alternative way:
newCertmagicConfig
with simplerconfigGetter
that operates on final certmagic inside of manager – this removes recursion and racy surface forcertmagic.*Default*
logic which is used if any of required fields is not set yetP2PForgeCertMgr.TLSConfig()
now explicitly usesP2PForgeCertMgr.certmagic.GetCertificate
to remove surface of any indirectionTogether, surface for racy behavior should be removed, allowing user to have default certmagic doing some unrelated things, and then one or more lip2p with multiple instances of p2p-forge/client in their app, without interfering with each other.
TODO