-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
advancedtls: add PEMFileProvider implementation for on-file-change credential reloading #3826
Conversation
b9ee1b9
to
d7d2584
Compare
d7d2584
to
9dff771
Compare
I've modified the tests as we discussed. @easwars Can you please take a look when you get a chance please? Thank you so much! |
The certificate provider API update just landed: #3797 |
@easwars Yes, I think the changes are up-to-date with your newest implementations. |
t.Run(test.desc, func(t *testing.T) { | ||
stage := &stageInfo{} | ||
oldReadKeyCertPairFunc := readKeyCertPairFunc | ||
readKeyCertPairFunc = func(certFile, keyFile string) (tls.Certificate, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option here is to use https://golang.org/pkg/io/ioutil/#TempFile, and populate them with actual contents, so that you dont have to override the readKeyCertPairFunc
and readTrustCertFunc
. That way you will also be exercising the functionality in readTrustCertFunc
. This need not be done as part of this PR. But if you feel this is a good idea, then you can add a TODO and do it in a later PR.
With this approach, you would not need any of this stage
business. You would write actual contents into the temp files from your test, and pass the tempFile path to the code which will read directly from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, actually we originally used this TempFile in #3785, but later changed to this implementation because we think making changes to local file system(even though it's in tmp folder) might be too much for unit tests.
I might use this when writing the integration tests, or when creating examples for the whole dynamic loading feature. Anyway thanks for the suggestions!
6da7a7c
to
9998493
Compare
@easwars Thank you again for the review! |
This is fork of work #3785.
This PR added implementation and unit tests of PemFileProvider. It will fetch identity certificate updates and root certificate updates from the identity PEM file and the root PEM file specified by users via PemFileProviderOptions periodically.