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

Bad exception message in HandshakeHash.getFinishedHash

    Details

    • Subcomponent:
    • Resolved In Build:
      b75
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        It's possible to end up with this exception in ssl handshake code :

        Exception in thread "main" java.lang.Error: BAD
                at sun.security.ssl.HandshakeHash.getFinishedHash(HandshakeHash.java:249)
                at sun.security.ssl.HandshakeMessage$Finished.getFinished(HandshakeMessage.java:1945)
                at sun.security.ssl.HandshakeMessage$Finished.<init>(HandshakeMessage.java:1892)
                at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1192)
                at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1112)
                at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
                at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)

        That's not too informative. We should set the cause of exception when throwing an Error.

          Activity

          Hide
          coffeys Sean Coffey added a comment -
          setting the cause allows us to see much more detail like this example :

          Exception in thread "main" java.lang.Error: BAD
                  at sun.security.ssl.HandshakeHash.getFinishedHash(HandshakeHash.java:249)
                  at sun.security.ssl.HandshakeMessage$Finished.getFinished(HandshakeMessage.java:1945)
                  at sun.security.ssl.HandshakeMessage$Finished.<init>(HandshakeMessage.java:1892)
                  at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1192)
                  at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1112)
                  at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
                  at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
                  at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
                  at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1050)
                  at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
                  at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)
                  at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375)
                  at TestAEADCipher.readWithParticularCipher(TestAEADCipher.java:57)
                  at TestAEADCipher.runCipherTest(TestAEADCipher.java:33)
                  at TestAEADCipher.main(TestAEADCipher.java:23)
          Caused by: java.lang.RuntimeException: Could not clone digest
                  at sun.security.ssl.HandshakeHash.cloneDigest(HandshakeHash.java:194)
                  at sun.security.ssl.HandshakeHash.getFinishedHash(HandshakeHash.java:247)
                  ... 14 more
          Caused by: java.lang.CloneNotSupportedException: SHA-256
                  at sun.security.pkcs11.P11Digest.clone(P11Digest.java:316)
                  at java.security.MessageDigest$Delegate.clone(MessageDigest.java:556)
                  at sun.security.ssl.HandshakeHash.cloneDigest(HandshakeHash.java:191)
                  ... 15 more
          Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_STATE_UNSAVEABLE
                  at sun.security.pkcs11.wrapper.PKCS11.C_GetOperationState(Native Method)
                  at sun.security.pkcs11.P11Digest.clone(P11Digest.java:311)
                  ... 17 more
          Show
          coffeys Sean Coffey added a comment - setting the cause allows us to see much more detail like this example : Exception in thread "main" java.lang.Error: BAD         at sun.security.ssl.HandshakeHash.getFinishedHash(HandshakeHash.java:249)         at sun.security.ssl.HandshakeMessage$Finished.getFinished(HandshakeMessage.java:1945)         at sun.security.ssl.HandshakeMessage$Finished.<init>(HandshakeMessage.java:1892)         at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1192)         at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1112)         at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)         at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)         at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)         at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1050)         at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)         at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)         at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375)         at TestAEADCipher.readWithParticularCipher(TestAEADCipher.java:57)         at TestAEADCipher.runCipherTest(TestAEADCipher.java:33)         at TestAEADCipher.main(TestAEADCipher.java:23) Caused by: java.lang.RuntimeException: Could not clone digest         at sun.security.ssl.HandshakeHash.cloneDigest(HandshakeHash.java:194)         at sun.security.ssl.HandshakeHash.getFinishedHash(HandshakeHash.java:247)         ... 14 more Caused by: java.lang.CloneNotSupportedException: SHA-256         at sun.security.pkcs11.P11Digest.clone(P11Digest.java:316)         at java.security.MessageDigest$Delegate.clone(MessageDigest.java:556)         at sun.security.ssl.HandshakeHash.cloneDigest(HandshakeHash.java:191)         ... 15 more Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_STATE_UNSAVEABLE         at sun.security.pkcs11.wrapper.PKCS11.C_GetOperationState(Native Method)         at sun.security.pkcs11.P11Digest.clone(P11Digest.java:311)         ... 17 more
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/3704b4f8b2be
          User: coffeys
          Date: 2015-07-17 09:38:16 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/3704b4f8b2be User: coffeys Date: 2015-07-17 09:38:16 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/3704b4f8b2be
          User: lana
          Date: 2015-07-29 20:40:19 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/3704b4f8b2be User: lana Date: 2015-07-29 20:40:19 +0000

            People

            • Assignee:
              coffeys Sean Coffey
              Reporter:
              coffeys Sean Coffey
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: