-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fixed CertUtils.handleOtherKeys() behavior with Cavium #4556
Conversation
Fixes fabric8io#4509 This took a while to find the root cause: The internal SPI fallback logic inside `KeyFactory.generatePrivate()` has the weird side effect of latching onto the LAST registered provider (which in our case was Cavium) after `InvalidKeySpecException` is thrown. This choice is sticky for a single instance of KeyFactory and the fix for our issue is to get fresh `KeyFactory` instance when retrying.
This includes a fix for fabric8io#4556
Here is a simple repro showing that re-using the KeyFactory after an exception results in a different Provider than using a fresh KeyFactory:
|
The style violation is pre-existing, not sure if I should be fixing it as part of the PR. |
@sfc-gh-jkowalski just run mvn spotless:apply then commit those changes. There was an outstanding issue / pr to bulk format the remaining files in the codebase, but it hasn't been committed. |
@shawkins done. |
SonarCloud Quality Gate failed. |
So this style change now triggered code coverage warning. Could this PR be merged as-is or do you want me to do something about code coverage? |
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
Don't worry about the coverage report, your core change is straight-forward.
Is there anything blocking merging this PR? |
} catch (InvalidKeySpecException e) { | ||
// Otherwise try PKCS8 | ||
RSAPrivateCrtKeySpec keySpec = PKCS1Util.decodePKCS1(keyBytes); | ||
return keyFactory.generatePrivate(keySpec); | ||
return KeyFactory.getInstance(clientKeyAlgo).generatePrivate(keySpec); |
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.
The fix is brittle without a test that ensures this won't be reverted in the future.
A test would be good, but at least a comment pointing to the issue should be added here.
Description
Fixes #4509
This took a while to find the root cause:
The internal SPI fallback logic inside
KeyFactory.generatePrivate()
has the weird side effect of latching onto the LAST registered provider (which in our case was Cavium) afterInvalidKeySpecException
is thrown.This choice is sticky for a single instance of KeyFactory and the fix for our issue is to get fresh
KeyFactory
instance when retrying.Type of change
test, version modification, documentation, etc.)
Checklist