BAEL-6898: Add Debug property for ssl Handshakes (#14822)

This commit is contained in:
Harry9656 2023-10-09 09:53:54 +02:00 committed by GitHub
parent 0e7c032aa8
commit 901951bff7
3 changed files with 14 additions and 15 deletions

View File

@ -7,7 +7,7 @@ import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class SecureConnection {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("Use: SecureConnection host port");
@ -20,20 +20,20 @@ public class SecureConnection {
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(host, port);
InputStream in = sslsocket.getInputStream();
OutputStream out = sslsocket.getOutputStream();
out.write(1);
while (in.available() > 0) {
System.out.print(in.read());
}
System.out.println("Secured connection performed successfully");
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Get the host from arguments
* @param args the arguments
@ -42,7 +42,7 @@ public class SecureConnection {
private static String getHost(String[] args) {
return args[0];
}
/**
* Get the port from arguments
* @param args the arguments

View File

@ -15,10 +15,8 @@ public class SimpleClient {
SocketFactory factory = SSLSocketFactory.getDefault();
try (Socket connection = factory.createSocket(host, port)) {
((SSLSocket) connection).setEnabledCipherSuites(
new String[] { "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"});
((SSLSocket) connection).setEnabledProtocols(
new String[] { "TLSv1.2"});
((SSLSocket) connection).setEnabledCipherSuites(new String[] { "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" });
((SSLSocket) connection).setEnabledProtocols(new String[] { "TLSv1.2" });
SSLParameters sslParams = new SSLParameters();
sslParams.setEndpointIdentificationAlgorithm("HTTPS");
((SSLSocket) connection).setSSLParameters(sslParams);
@ -28,6 +26,7 @@ public class SimpleClient {
}
public static void main(String[] args) throws IOException {
System.setProperty("javax.net.debug", "ssl:handshake");
System.out.println(startClient("localhost", 8443));
}
}

View File

@ -14,11 +14,10 @@ public class SimpleServer {
ServerSocketFactory factory = SSLServerSocketFactory.getDefault();
try (ServerSocket listener = factory.createServerSocket(port)) {
System.setProperty("javax.net.debug", "ssl:handshake");
((SSLServerSocket) listener).setNeedClientAuth(true);
((SSLServerSocket) listener).setEnabledCipherSuites(
new String[] { "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"});
((SSLServerSocket) listener).setEnabledProtocols(
new String[] { "TLSv1.2"});
((SSLServerSocket) listener).setEnabledCipherSuites(new String[] { "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" });
((SSLServerSocket) listener).setEnabledProtocols(new String[] { "TLSv1.2" });
while (true) {
try (Socket socket = listener.accept()) {
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
@ -29,6 +28,7 @@ public class SimpleServer {
}
public static void main(String[] args) throws IOException {
System.setProperty("javax.net.debug", "ssl:handshake");
startServer(8443);
}
}