Skip to content

Commit

Permalink
Issue #6072 - Adding SSLEngineTest.testBigTlsRequest testcase to repl…
Browse files Browse the repository at this point in the history
…icate

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Mar 18, 2021
1 parent 6b34190 commit f1c3c2e
Showing 1 changed file with 35 additions and 0 deletions.
Expand Up @@ -34,6 +34,7 @@
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -191,6 +192,40 @@ public void testBigResponse() throws Exception
assertThat(response.length(), greaterThan(102400));
}

@Test
public void testBigTlsRequest() throws Exception
{
server.setHandler(new HelloWorldHandler());
server.start();

// Create raw TLS record.
byte[] bytes = new byte[20005];
bytes[0] = 22; // record type
bytes[1] = 3; // major version
bytes[2] = 3; // minor version
bytes[3] = 78; // record length 2 bytes
bytes[4] = 32; // record length

bytes[5] = 1; // message type
bytes[6] = 0; // message length 3 bytes
bytes[7] = 78;
bytes[8] = 23;

for (int i = 9; i < bytes.length; i++)
{
bytes[i] = 1;
}

SocketFactory socketFactory = SocketFactory.getDefault();
try (Socket client = socketFactory.createSocket("localhost", connector.getLocalPort()))
{
client.getOutputStream().write(bytes);

String response = IO.toString(client.getInputStream());
assertThat(response.length(), greaterThan(102400));
}
}

@Test
public void testRequestJettyHttps() throws Exception
{
Expand Down

0 comments on commit f1c3c2e

Please sign in to comment.