Repository navigation
Enable Dynamic Reloading of TLS Certificates and Keys - #642
Conversation
… of TLS certificates and keys
hanahmily
left a comment
There was a problem hiding this comment.
Please revert all your changes to the test. The current test can run successfully without your modifications. If it fails, the only reason is your changes.
d6dbce5 to
2418f66
Compare
…- Remove explanatory comments from pkg/tls/reloader.go , - Add unit tests to verify certificate reloading behavior
…- Remove explanatory comments from pkg/tls/reloader.go , - Add unit tests to verify certificate reloading behavior
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #642 +/- ##
===========================================
+ Coverage 35.37% 51.46% +16.08%
===========================================
Files 182 183 +1
Lines 25447 25762 +315
===========================================
+ Hits 9003 13259 +4256
+ Misses 15734 11397 -4337
- Partials 710 1106 +396 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hanahmily
left a comment
There was a problem hiding this comment.
The test cases are mostly incorrect. You cannot load the certificates manually to assist the reloader, which does not verify the watcher.
hanahmily
left a comment
There was a problem hiding this comment.
.The number of test cases is too large to review. Please limit them to less than five functions to cover the core scenarios I mentioned earlier.
|
The reloader seems good to me, although there are a few minor issues to address. Let's move on to the next test: Add the following:
gm.Eventually(func(innerGm gm.Gomega) {
casesMeasureData.VerifyFn(innerGm, helpers.SharedContext{
Connection: conn,
BaseTime: baseTime,
}, helpers.Args{Input: "all", Duration: 25 * time.Minute, Offset: -20 * time.Minute})
}, flags.EventuallyTimeout).Should(gm.Succeed()) |
acd527a to
99ac5c0
Compare
hanahmily
left a comment
There was a problem hiding this comment.
The last step should test the HTTP server.
be4ff7b to
60917ac
Compare
Signed-off-by: Gao Hongtao <[email protected]>
Signed-off-by: Gao Hongtao <[email protected]>
Feature Description
BanyanDB currently supports TLS for encrypted communication between clients and the server. However, it lacks the capability to automatically reload updated TLS certificates and keys without requiring a server restart. This feature implements dynamic reloading of TLS materials, enhancing operational flexibility and security.
Testing
rm -rf test-certs && mkdir test-certs && cd test-certs
Step 1: Generate initial cert/key pair
openssl req -x509 -newkey rsa:2048 -keyout key1.pem -out cert1.pem -days 365 -nodes -subj "/CN=localhost"
cp cert1.pem cert.pem && cp key1.pem key.pem
Step 2: Start the server with TLS
./banyand/build/bin/dev/banyand-server standalone --tls=true --cert-file=test-certs/cert.pem --key-file=test-certs/key.pem --http-tls=true --http-cert-file=test-certs/cert.pem --http-key-file=test-certs/key.pem --http-grpc-cert-file=test-certs/cert.pem
Step 3: Verify the initial certificate
echo "Port 17912:" && echo | openssl s_client -connect localhost:17912 2>/dev/null | openssl x509 -noout -subject
echo "Port 17913:" && echo | openssl s_client -connect localhost:17913 2>/dev/null | openssl x509 -noout -subject
Step 4: Update cert/key pair
openssl req -x509 -newkey rsa:2048 -keyout key2.pem -out cert2.pem -days 365 -nodes -subj "/CN=localhost-new"
cp cert2.pem cert.pem && cp key2.pem key.pem
Step 5: Check if the new certificate is used without restarting
echo "Port 17912:" && echo | openssl s_client -connect localhost:17912 2>/dev/null | openssl x509 -noout -subject
echo "Port 17913:" && echo | openssl s_client -connect localhost:17913 2>/dev/null | openssl x509 -noout -subject
Checklist