ASF Bugzilla – Attachment 37059 Details for
Bug 64195
Tomcat NIO SSL Connector broken under Linux in Tomcat 9.0.31
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
DemoClient
DemoClient.java (text/plain), 2.19 KB, created by
Michael Seele
on 2020-03-04 12:38:22 UTC
(
hide
)
Description:
DemoClient
Filename:
MIME Type:
Creator:
Michael Seele
Created:
2020-03-04 12:38:22 UTC
Size:
2.19 KB
patch
obsolete
>package de.guhsoft.tomcat; > >import java.io.IOException; >import java.net.URI; >import java.net.http.HttpClient; >import java.net.http.HttpRequest; >import java.net.http.HttpResponse; >import java.util.Arrays; > >import javax.net.ssl.SSLContext; >import javax.net.ssl.TrustManager; >import javax.net.ssl.X509TrustManager; > >public class DemoClient { > > public static void main(String[] args) throws Throwable { > // trust all certificates > System.getProperties() > .setProperty("jdk.internal.httpclient.disableHostnameVerification", Boolean.TRUE.toString()); //$NON-NLS-1$ > TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { > @Override > public java.security.cert.X509Certificate[] getAcceptedIssuers() { > return null; > } > > @Override > public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { > // accept all > } > > @Override > public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { > // accept all > } > } }; > SSLContext sc = SSLContext.getInstance("SSL"); //$NON-NLS-1$ > sc.init(null, trustAllCerts, new java.security.SecureRandom()); > > HttpClient client = HttpClient.newBuilder() > .sslContext(sc) > .build(); > > byte[] bytes = new byte[1024 * 1024]; // 1MB > Arrays.fill(bytes, (byte) 1); > > HttpRequest request = HttpRequest.newBuilder() > .uri(URI.create(args[0] + "/send_back")) //$NON-NLS-1$ > .POST(HttpRequest.BodyPublishers.ofByteArray(bytes)) > .build(); > > for (int i = 0; i < 100; i++) { > System.err.println(i + 1); > try { > byte[] response = client.send(request, HttpResponse.BodyHandlers.ofByteArray()).body(); > if (Arrays.equals(bytes, response)) { > System.err.println("SUCCESS"); //$NON-NLS-1$ > } else { > System.err.println("[ERROR] RESULT NOT EQUAL: expected " + bytes.length + " / got: " + response.length); //$NON-NLS-1$ //$NON-NLS-2$ > } > } catch (IOException | InterruptedException e) { > System.err.println("[ERROR] Exception: " + e.getMessage()); //$NON-NLS-1$ > e.printStackTrace(); > } > System.err.println("------------------"); //$NON-NLS-1$ > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 64195
:
37058
| 37059