-
Notifications
You must be signed in to change notification settings - Fork 61
Allow re-importing the client TLS certifcate. #1743
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1743 +/- ##
==========================================
- Coverage 84.98% 81.40% -3.58%
==========================================
Files 178 178
Lines 12019 12561 +542
==========================================
+ Hits 10214 10225 +11
- Misses 1805 2336 +531
Continue to review full report at Codecov.
|
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.
LGTM.
Thanks. Unfortunately I just tested it in a more realistic use case and it isn't working. Still investigating. For now, we should wait on merging. |
Is there unit-test for the previous version (root CA re-import)? |
False alarm, it was just because trying to reimport the key, too, which I haven't allowed here. For just the cert, it works fine.
Yep, the same test that I edited to test the new functionality. |
1e4ec83
to
3608f74
Compare
5097ce1
to
ece2479
Compare
I've updated this, tested it more thoroughly, removed the do-not-merge tag, and in the process (automatically) dismissed @zabbal's review. This is now ready for review again. |
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.
Looks good.
A little side note: the importUpdateSimple() is defined and used only in invstorage.cc - do we really need to expose it in public API? Can it be marked static instead?
Doesn't appear to be part of the public API (
I tried that recently (unrelated to this) but I wasn't able to make it work. |
Nevermind then - most likely that's smth "lost in translation" while trying to apply my C experience to C++ world. |
We already allow it for the root CA. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
ece2479
to
8c144ce
Compare
a300a58
to
04edbfb
Compare
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
This enables the shared credential hack to help test cert replacement. Note that the relevant parameter is --certificate-cn because that's how it's used for the proper fleet CA method. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
This logic is now only in once place (in the Crypto class) and the KeyManager function just uses that directly. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Also refactor to use RSA_generate_key_ex instead of the deprecated RSA_generate_key. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
04edbfb
to
8bf559a
Compare
I did a bunch of refactoring in order to be able to generate certificates so I could appropriately test the situation where a new certificate has a different device ID, which we've decided is not allowed. |
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.
Looks pretty neat overall.
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.
OTF tests have passed:
test_06_replace_device_certificate_using_fleet_root_ca
test_07_invalid_certificate_not_accepted_by_backend
test_08_device_certificate_with_new_device_id_not_allowed
…functions. This allows for much easier reuse of the specific parts. Also switch to exceptions instead of printing and returning false. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
This should only be used for testing, so it prints a message to tell you that. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Expand the test to check the negative case (with a different device ID) as well. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
8bf559a
to
dcad65b
Compare
@Raigi is this still good with latest changes? |
She's away this week, but very little changed from the version she was testing. I think this is safe to merge. |
We already allow it for the root CA.