-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[Backport] Fix parsing of PBES2 encrypted PKCS#8 keys #79352
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
[Backport] Fix parsing of PBES2 encrypted PKCS#8 keys #79352
Conversation
This commit adds support for decrypting PKCS#8 encoded private keys that have been encrypted using a PBES2 based scheme (AES only). Unfortunately `java.crypto.EncryptedPrivateKeyInfo` doesn't make this easy as the underlying encryption algorithm is hidden within the `AlgorithmParameters`, and can only be extracted by calling `toString()` on the parameters object. See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4 See: AlgorithmParameters#toString() See: com.sun.crypto.provider.PBES2Parameters#toString() Backport of: elastic#78904
Pinging @elastic/es-security (Team:Security) |
@jkakavas As part of the backport, I added special case code for JDK8 because the JDK enhancements we rely on were backported to 8 |
Turns out it is supported on Oracle JDK8, but not OpenJDK8 |
@elasticmachine update branch |
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, sorry I missed the original ping for the review. I added a comment about the oracle vs openjdk 8 case but I'm fine as it is now.
} | ||
if (JavaVersion.current().compareTo(JavaVersion.parse("11.0.0")) < 0) { | ||
// PBES2 appears to be supported on Oracle 8, but not OpenJDK8 | ||
// We don't both clarifying that here because it is supported on the bundled JDK, and that's what people should use |
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.
both -> bother ( in case you need to make another commit for another reason)
libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemUtils.java
Outdated
Show resolved
Hide resolved
This commit adds support for decrypting PKCS#8 encoded private keys that have been encrypted using a PBES2 based scheme (AES only). Unfortunately `java.crypto.EncryptedPrivateKeyInfo` doesn't make this easy as the underlying encryption algorithm is hidden within the `AlgorithmParameters`, and can only be extracted by calling `toString()` on the parameters object. See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4 See: AlgorithmParameters#toString() See: com.sun.crypto.provider.PBES2Parameters#toString() This support is conditional on the underlying support in the JDK, which is absent from OpenJDK 8, but should work on all other supported JDKs. Backport of: elastic#78904 Backport of: elastic#79352
This commit adds support for decrypting PKCS#8 encoded private keys that have been encrypted using a PBES2 based scheme (AES only). Unfortunately `java.crypto.EncryptedPrivateKeyInfo` doesn't make this easy as the underlying encryption algorithm is hidden within the `AlgorithmParameters`, and can only be extracted by calling `toString()` on the parameters object. See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4 See: AlgorithmParameters#toString() See: com.sun.crypto.provider.PBES2Parameters#toString() This support is conditional on the underlying support in the JDK, which is absent from OpenJDK 8, but should work on all other supported JDKs. Backport of: #78904 Backport of: #79352
This commit adds support for decrypting PKCS#8 encoded private keys
that have been encrypted using a PBES2 based scheme (AES only).
Unfortunately
java.crypto.EncryptedPrivateKeyInfo
doesn't make thiseasy as the underlying encryption algorithm is hidden within the
AlgorithmParameters
, and can only be extracted by callingtoString()
on the parameters object.See: https://datatracker.ietf.org/doc/html/rfc8018#appendix-A.4
See: AlgorithmParameters#toString()
See: com.sun.crypto.provider.PBES2Parameters#toString()
Backport of: #78904