RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1993150 - java-1.8.0-openjdk / rhel-9: OpenJDK cannot read keystore generated by OpenSSL
Summary: java-1.8.0-openjdk / rhel-9: OpenJDK cannot read keystore generated by OpenSSL
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: java-1.8.0-openjdk
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: beta
: ---
Assignee: Andrew John Hughes
QA Contact: OpenJDK QA
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-08-12 13:32 UTC by zzambers
Modified: 2023-02-12 07:27 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1993142
Environment:
Last Closed: 2023-02-12 07:27:43 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-93386 0 None None None 2021-08-12 13:33:32 UTC
openjdk bug system JDK-8076190 0 None None None 2021-08-20 04:38:20 UTC

Description zzambers 2021-08-12 13:32:10 UTC
+++ This bug was initially created as a clone of Bug #1993142 +++

OpenJDK fails to read keystore generated by OpenSSL:

JDK11 rpms:
/usr/lib/jvm/java-11-openjdk/bin/keytool -J-Dcom.redhat.fips=false  -importkeystore \
-srckeystore build/certgen/keystore-rsa.p12 -srcstoretype PKCS12 \
-srcstorepass changeit \
-destkeystore build/certgen/keystore.p12 -deststoretype PKCS12 \
-deststorepass changeit \
-noprompt -v
Importing keystore build/certgen/keystore-rsa.p12 to build/certgen/keystore.p12...
keytool error: java.io.IOException: keystore password was incorrect
java.io.IOException: keystore password was incorrect
    at java.base/sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2117)
    at java.base/sun.security.util.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:222)
    at java.base/java.security.KeyStore.load(KeyStore.java:1479)
    at java.base/sun.security.tools.keytool.Main.loadSourceKeyStore(Main.java:2200)
    at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1200)
    at java.base/sun.security.tools.keytool.Main.run(Main.java:409)
    at java.base/sun.security.tools.keytool.Main.main(Main.java:402)
Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
    ... 7 more

JDK8 rpms:
keytool -J-Dcom.redhat.fips=false  -importkeystore \
-srckeystore build/certgen/keystore-rsa.p12 -srcstoretype PKCS12 \
-srcstorepass changeit \
-destkeystore build/certgen/keystore.p12 -deststoretype PKCS12 \
-deststorepass changeit \
-noprompt -v
Importing keystore build/certgen/keystore-rsa.p12 to build/certgen/keystore.p12...
keytool error: java.io.IOException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
java.io.IOException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
    at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:829)
    at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2037)
    at java.security.KeyStore.load(KeyStore.java:1445)
    at sun.security.tools.keytool.Main.loadSourceKeyStore(Main.java:2061)
    at sun.security.tools.keytool.Main.doCommands(Main.java:1080)
    at sun.security.tools.keytool.Main.run(Main.java:377)
    at sun.security.tools.keytool.Main.main(Main.java:370)
Caused by: java.io.IOException: ObjectIdentifier() -- data isn't an object ID (tag = 48)
    at sun.security.util.ObjectIdentifier.<init>(ObjectIdentifier.java:285)
    at sun.security.util.DerInputStream.getOID(DerInputStream.java:320)
    at com.sun.crypto.provider.PBES2Parameters.engineInit(PBES2Parameters.java:267)
    at java.security.AlgorithmParameters.init(AlgorithmParameters.java:293)
    at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:825)
    ... 6 more 


Steps to Reproduce:
Can by reproduced by ssl-tests [1]:
export JAVA_HOME=...
make ssl-tests

or just by reading pkcs12 keystore generated by openssl on rhel-9 by keytool

openjdk:
java-11-openjdk-headless-11.0.11.0.9-1.el9
java-1.8.0-openjdk-headless-1.8.0.302.b08-0.el9

openssl:
compat-openssl11-1.1.1k-1.el9.x86_64
openssl-3.0.0-0.beta2.2.el9.x86_64
openssl-devel-3.0.0-0.beta2.2.el9.x86_64
openssl-libs-3.0.0-0.beta2.2.el9.x86_64
openssl-pkcs11-0.4.11-6.el9.x86_64


I also tested builds, built locally from current upstream repos:

jdk (2021-08-11)
OK

jdk11u-dev (2021-08-11)
OK

jdk8u (2021-08-11)
/mnt/workspace/jdk8u-2021-08-11-el8/bin/keytool -J-Dcom.redhat.fips=false  -importkeystore \
-srckeystore build/certgen/keystore-rsa.p12 -srcstoretype PKCS12 \
-srcstorepass changeit \
-destkeystore build/certgen/keystore.p12 -deststoretype PKCS12 \
-deststorepass changeit \
-noprompt -v
Importing keystore build/certgen/keystore-rsa.p12 to build/certgen/keystore.p12...
keytool error: java.io.IOException: keystore password was incorrect
java.io.IOException: keystore password was incorrect
	at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2079)
	at java.security.KeyStore.load(KeyStore.java:1445)
	at sun.security.tools.keytool.Main.loadSourceKeyStore(Main.java:2057)
	at sun.security.tools.keytool.Main.doCommands(Main.java:1076)
	at sun.security.tools.keytool.Main.run(Main.java:375)
	at sun.security.tools.keytool.Main.main(Main.java:368)
Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
	... 6 more


So current JDK has fix for this, also looks like fix was backported to JDK11, but JDK8 is currently still affected. I think this issue was probably fixed by JDK-8076190 [2], which was backported to JDK11, but JDK8 backport is still in-progress.

[1] https://github.com/zzambers/ssl-tests
[2] https://bugs.openjdk.java.net/browse/JDK-8076190

--- Additional comment from  on 2021-08-12 15:27:13 CEST ---

keystore generated by openssl on rhel-9, which can be used for testing,
password: changeit

Comment 2 RHEL Program Management 2023-02-12 07:27:43 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.


Note You need to log in before you can comment on or make changes to this bug.