Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8158633

BASE64 encoded cert not correctly parsed with UTF-16

    Details

    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b124
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        Java HotSpot(TM) 64-Bit Server VM (build 25.102-b04, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        windows 10 64

        A DESCRIPTION OF THE PROBLEM :
        simple connect https website,it could not work when use utf-16 in source file

        REGRESSION. Last worked in version 8u74

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        public class Test {
        public static void main(String[] args) throws Exception {
        URLConnection openConnection = new URL("https://www.google.com").openConnection();
        openConnection.connect();
        }
        }


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        simple code above,if save as utf-8,it runs ok,if save as utf-16,it crash
        ACTUAL -
        report error

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "main" java.lang.ExceptionInInitializerError
        at javax.crypto.JceSecurity.loadPolicies(JceSecurity.java:317)
        at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:262)
        at javax.crypto.JceSecurity.access$000(JceSecurity.java:48)
        at javax.crypto.JceSecurity$1.run(JceSecurity.java:80)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:77)
        at javax.crypto.JceSecurityManager.<clinit>(JceSecurityManager.java:65)
        at javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2587)
        at javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2611)
        at sun.security.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:548)
        at sun.security.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:527)
        at sun.security.ssl.CipherSuite.isAvailable(CipherSuite.java:194)
        at sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(SSLContextImpl.java:346)
        at sun.security.ssl.SSLContextImpl.getDefaultCipherSuiteList(SSLContextImpl.java:304)
        at sun.security.ssl.SSLSocketImpl.init(SSLSocketImpl.java:626)
        at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:537)
        at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:72)
        at sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:405)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:162)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
        at sun.net.www.protocol.https.HttpsClient.&lt;init&gt;(HttpsClient.java:264)
        at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
        at Test.main(Test.java:7)
        Caused by: java.lang.SecurityException: Framework jar verification can not be initialized
        at javax.crypto.JarVerifier.<clinit>(JarVerifier.java:192)
        ... 29 more
        Caused by: java.security.PrivilegedActionException: java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: java.lang.IllegalArgumentException: Illegal base64 character -2
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.crypto.JarVerifier.<clinit>(JarVerifier.java:151)
        ... 29 more
        Caused by: java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: java.lang.IllegalArgumentException: Illegal base64 character -2
        at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:110)
        at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)
        at javax.crypto.JarVerifier.parseCertificate(JarVerifier.java:206)
        at javax.crypto.JarVerifier.access$100(JarVerifier.java:37)
        at javax.crypto.JarVerifier$1.run(JarVerifier.java:158)
        at javax.crypto.JarVerifier$1.run(JarVerifier.java:152)
        ... 31 more
        Caused by: java.io.IOException: java.lang.IllegalArgumentException: Illegal base64 character -2
        at sun.security.util.Pem.decode(Pem.java:49)
        at sun.security.provider.X509Factory.readOneBlock(X509Factory.java:638)
        at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:96)
        ... 36 more
        Caused by: java.lang.IllegalArgumentException: Illegal base64 character -2
        at java.util.Base64$Decoder.decode0(Base64.java:714)
        at java.util.Base64$Decoder.decode(Base64.java:526)
        at sun.security.util.Pem.decode(Pem.java:47)
        ... 38 more

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class Test {
        public static void main(String[] args) throws Exception {
        URLConnection openConnection = new URL("https://www.google.com").openConnection();
        openConnection.connect();
        }
        }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  weijun Weijun Wang
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: