test/jdk/javax/net/ssl/DTLS/InvalidRecords.java
changeset 50768 68fa3d4026ea
parent 47216 71c04702a3d5
child 58013 d80e4bce4588
--- a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java	Mon Jun 25 21:22:16 2018 +0300
+++ b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java	Mon Jun 25 13:41:39 2018 -0700
@@ -55,7 +55,7 @@
 
     @Override
     DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) {
-        if (needInvalidRecords && (ba.length >= 60) &&
+        if ((ba.length >= 60) &&
                 (ba[0x00] == (byte)0x16) && (ba[0x0D] == (byte)0x01) &&
                 (ba[0x3B] == (byte)0x00) && (ba[0x3C] > 0)) {
 
@@ -64,6 +64,16 @@
             // ba[0x3B]: length of session ID
             // ba[0x3C]: length of cookie
 
+            if (!needInvalidRecords) {
+                // The 2nd ClientHello with cookie.  The 1st one should be
+                // rejected as expected.
+                //
+                // This may happen if the last few bytes of the packet are
+                // for supported_version extension.
+                throw new RuntimeException(
+                    "the crashed handshake message was rejected as expected");
+            }
+
             // ClientHello with cookie
             needInvalidRecords = false;
             System.out.println("invalidate ClientHello message");