Add code for enabling SSL Debug logs
This commit is contained in:
parent
9801f1eb7d
commit
4b5a9dfbad
|
@ -0,0 +1,32 @@
|
||||||
|
package com.baeldung.enablessldebug;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class SSLDebugLogger {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SSLDebugLogger.class);
|
||||||
|
|
||||||
|
public static void enableSSLDebugUsingSystemProperties() {
|
||||||
|
System.setProperty("javax.net.debug", "ssl");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void makeHttpsRequest() throws Exception {
|
||||||
|
String url = "https://github.com/eugenp/tutorials";
|
||||||
|
URL httpsUrl = new URL(url);
|
||||||
|
HttpsURLConnection connection = (HttpsURLConnection) httpsUrl.openConnection();
|
||||||
|
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||||
|
String line;
|
||||||
|
logger.info("Response from " + url + ":");
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
logger.info(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue