fix(client): race in cert renewal #42
Draft
+53
−63
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