-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Replaced openssl with Java security to add key/cert into keystore #11224
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Paolo Patierno <[email protected]>
I am opening this PR to discuss it because we are not going to have exactly the same result as described. |
Signed-off-by: Paolo Patierno <[email protected]>
Signed-off-by: Paolo Patierno <[email protected]>
.optArg("-keypbe", "aes-128-cbc") | ||
.optArg("-macalg", "sha256") | ||
.exec(); | ||
public void addKeyAndCertToKeyStore(File keyFile, File certFile, String alias, File keyStoreFile, String keyStorePassword) |
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.
Just curious...Shouldn't this method be moved to the CertManager
class instead of being in OpenSslCertManager
as it does not use any OpenSSL invocation method?
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.
That's a good point, however there are other methods not using openssl anymore already (i.e. addCertToTrustStore
, deleteFromTrustStore
, ...). At some point we could think about renaming it to not be strictly tight to OpenSsl.
Signed-off-by: Paolo Patierno <[email protected]>
/azp run regression |
Azure Pipelines successfully started running 1 pipeline(s). |
This PR is going to replace the usage of OpenSSL tooling for adding a key/cert pair to the keystore with Java security framework.
While running tests I compared what we get by using openssl and what we get with Java.
I was able to tune the algorithm being used to encrypt the private key when it's stored, in order to have AES-128-CBC with 2048 iterations (which are the parameters with current openssl tooling vs the default Java which uses AES-256-CBC and 10000 iterations instead).
The only difference is about the HMAC used for the keystore integrity.
The openssl tool uses 2048 iterations and salt length 8 bytes.
Java defaults to use 10000 iterations and salt length 10 bytes.
I couldn't find any way to tune them both. Java doesn't expose anything to do so. It's only possible to tune the iterations but by setting a global Java properties like this:
Tbh I am not keen to have such addition because it would be a global setting on the JVM.
So compared to openssl with have more secure HMAC which should not be a problem (the opposite I would say).