JDK-8201290 : keytool importcert fails with CertificateParsingException if unknown certificate algorithms should be imported
  • Type: Enhancement
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 8,9,10,11
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2018-04-06
  • Updated: 2018-08-17
  • Resolved: 2018-08-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12
12 b07Fixed
Related Reports
CSR :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
I'm using a certificate using a Brainpool elliptic curve parameter. This is not supported in Java 8. I was searching if it is possible to provide a different crypto provider, e.g. BouncyCastle. This was working to migrate PKCS#12 keystores into a JSK keystore. But for importing a simple certificate into a truststore such an option is not available. This prevent to use such an certificate in a truststore which results in not being able to start a TLS based server needed this truststore for the CI certificate.

JUSTIFICATION :
The Brainpool elliptic curve is a standard used today. It should be supported, but also in the case of a new or different algorithmic parameter it should be possible to supply a source crypto provider which is able to handle it correctly.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The certificate should be imported.
ACTUAL -
The following exception is thrown:

Keytool-Fehler: java.security.cert.CertificateParsingException: java.io.IOException: Unknown named curve: 1.3.36.3.3.2.8.1.1.7

---------- BEGIN SOURCE ----------
See the needed data in the patched project:

https://github.com/koh-osug/java-keytool

keytool.exe-importcert -alias ci -file CERT_CI_ECDSA_BRP.der -keystore truststore.jks -providerPath bcprov-jdk15on-1.59.jar -v -providerClass org.bouncycastle.jce.provider.BouncyCastleProvider
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None, but I have released a patched version:

https://github.com/koh-osug/java-keytool

The only needed change starts at line 916:

https://github.com/koh-osug/java-keytool/blob/master/src/main/java/sun/security/tools/keytool/Main2.java#L916

            if (srcProviderName != null) {
                cf = CertificateFactory.getInstance("X509", srcProviderName);
            }
            else {
                cf = CertificateFactory.getInstance("X509");
            }


Comments
The keytool command succeeds now. On the other hand, this bug is about finding a way to deal with unsupported algorithm parameters. For example, the following command still fails: openssl ecparam -name c2pnb368w1 -genkey -out ec openssl req -new -key ec -subj /CN=A -x509 | keytool -printcert -debug
01-08-2018

@weijun, does JDK-7007966 now fix this issue? If so, can you close it?
31-07-2018