<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<div><br></div><div>since the backport of the new TLS 1.3 capable JSSE provider the debug logging of JSSE has changed. This is due to the usage of unified logging, which is not available on Java 8.</div><div><br></div><div>There are some hints in the backport ticket (16 New Debug Logger):</div><div><br></div><div><a href="https://bugs.openjdk.java.net/browse/JDK-8248721">https://bugs.openjdk.java.net/browse/JDK-8248721</a><br></div><div><br></div><div>- in versions before the backport I could specify -Djavax.net.debug=all to turn on internal debug logging.</div><div>- This was sent to stdout and it DID honor System.setOut() redirection. </div><div><br></div><div>This especially means on an application server like JBoss the output is redirected to the (rolling) application server main logfile, but in the last two quarterly updates, this is no longer the case.</div><div><br></div><div>This looks like a regression to me, the new internal debug loggers used by JSSE should still write to System.out (and honor redirect)</div><div><br></div><div>However, I see that the new JUL logger (and in future the platform logger) have their benefit, so suppose I want to make changes to my existing code to accommodate this, how can I actually access and redirect those log messages? According to the backport request there is some difference between requesting a JUL logger or creating a internal one dependning on the value of the system propery.</div><div><br></div><div>So I tried to register a handler to see if I can catch those log messages, but I have not. It works for some messages like the Debug from X509Certificate, but it does not work for the handshake stuff:</div><div><br></div><div>(in the following console output "JUL " is from my handler and "java.net.ssl|..." is from the internal handling, it will not honor System.setOut redirects, either.)</div><div><br></div><div><div><font face="monospace" size="1">java version "1.8.0_261"</font></div><div><font face="monospace" size="1">Java(TM) SE Runtime Environment (build 1.8.0_261-b12)</font></div><div><font face="monospace" size="1">Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)</font></div><div><font face="monospace" size="1"><br></font></div><div><font face="monospace" size="1">JUL FINE|1604441741129 started</font></div><div><font face="monospace" size="1">JUL FINE|1604441741129 ssl started</font></div><div><font face="monospace" size="1">JUL FINE|1604441741129 ssl started</font></div><div><font face="monospace" size="1">Connect to <a href="https://www.google.com">https://www.google.com</a> ...</font></div><div><font face="monospace" size="1"><b>javax.net.ssl</b>|FINE|01|main|2020-11-03 23:15:41.270 CET|<b>SSLContextImpl.java</b>:425|System property jdk.tls.client.cipherSuites is set to 'null'</font></div><div><font face="monospace" size="1">javax.net.ssl|FINE|01|main|2020-11-03 23:15:41.275 CET|SSLContextImpl.java:425|System property jdk.tls.server.cipherSuites is set to 'null'</font></div><div><font face="monospace" size="1"><b>JUL FINE</b>|1604441741327 <b>X509Certificate</b>: Alg:{0}, Serial:{1}, Subject:{2}, Issuer:{3}, Key type:{4}, Length:{5}, Cert Id:{6}, Valid from:{7}, Valid until:{8}</font></div><div><font face="monospace" size="1">JUL FINE|1604441741328 X509Certificate: Alg:{0}, Serial:{1}, Subject:{2}, Issuer:{3}, Key type:{4}, Length:{5}, Cert Id:{6}, Valid from:{7}, Valid until:{8}</font></div></div><div><font face="monospace" size="1">...</font></div><div><div><font face="monospace" size="1">javax.net.ssl|FINE|01|main|2020-11-03 23:15:42.358 CET|Finished.java:522|Consuming server Finished handshake message (</font></div><div><font face="monospace" size="1">"Finished": {</font></div><div><font face="monospace" size="1">  "verify data": {</font></div><div><font face="monospace" size="1">    0000: 46 40 BF 48 6E 83 A9 7F   6A E0 5A 4D </font></div><div><font face="monospace" size="1">  }'}</font></div><div><font face="monospace" size="1">)</font></div><div><font face="monospace" size="1">JUL FINE|1604441742359  TLSHandshake: {0}:{1}, {2}, {3}, {4}</font></div><div><font face="monospace" size="1">Using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256</font></div><div><font face="monospace" size="1">-- iterates registered loggers:</font></div><div><font face="monospace" size="1">log javax.net.ssl null</font></div><div><font face="monospace" size="1">log sun.net.www.protocol.http.HttpURLConnection null</font></div><div><font face="monospace" size="1">log jdk.event.security null</font></div><div><font face="monospace" size="1">log global null</font></div><div><font face="monospace" size="1">log  ALL</font></div><div><font face="monospace" size="1">JUL close</font></div><div><font face="monospace" size="1">JUL close</font></div></div><div><br></div><div>...</div><div>I get the same output with -Djava.net.debug=all and -Djava.net.debug. Looks like the SSLContextImpl or Dinished.java is always using its own logger with no way to register an handler?<br></div><div><br></div><div>Gruss</div><div>Bernd</div><div><br></div><div>PS: the sample code is here:</div><div><br></div><div><div>/* SPDX-License-Identifier: apache-2.0 */</div><div>package net.eckenfels.test.ssl;</div><div><br></div><div>import java.io.File;</div><div>import java.io.FileOutputStream;</div><div>import java.io.IOException;</div><div>import java.io.PrintStream;</div><div>import java.net.HttpURLConnection;</div><div>import java.net.URL;</div><div>import java.util.Enumeration;</div><div>import java.util.logging.Handler;</div><div>import java.util.logging.Level;</div><div>import java.util.logging.LogManager;</div><div>import java.util.logging.LogRecord;</div><div>import java.util.logging.Logger;</div><div><br></div><div>import javax.net.ssl.HttpsURLConnection;</div><div><br></div><div>import net.eckenfels.test.ssl.UrlInspect.MyHandler;</div><div><br></div><div>public class UrlInspect<br></div><div>{</div><div>    public static class MyHandler extends Handler</div><div>    {</div><div>        @Override<br></div><div>        public void publish(LogRecord record) {</div><div>            System.out.println("JUL " + record.getLevel() + "|" + record.getMillis() + " " + record.getMessage());</div><div>        }</div><div><br></div><div>        @Override</div><div>        public void flush()  {</div><div>            System.out.println("JUL flush");</div><div>            System.out.flush();</div><div>        }</div><div><br></div><div>        @Override<br></div><div>        public void close() throws SecurityException {</div><div>            System.out.println("JUL close");</div><div>        }</div><div>    }<br></div><div><br></div><div>    public static void main(String[] args) throws IOException {</div><div>        Handler mh = new MyHandler();</div><div>        LogManager.getLogManager().reset();</div><div>        Logger root = LogManager.getLogManager().getLogger("");</div><div>        root.setLevel(Level.ALL);</div><div>        root.addHandler(mh);</div><div><br></div><div>        Logger log = Logger.getLogger("javax.net.ssl");<br></div><div>        log.addHandler(mh); // not needed</div><div><br></div><div>        root.fine("started");</div><div></div><div>        log.fine("ssl started");</div><div><br></div><div>        //FileOutputStream log = new FileOutputStream(new File("out.log"));<br></div><div>        //System.setOut(new PrintStream(log));</div><div>        //sun.util.logging.PlatformLogger.getLogger("sun.net.www.protocol.http.HttpsURLConnection") .setLevel(Level.ALL);<br></div><div><br></div><div>        URL url = new URL((args.length < 1)?"<a href="https://developer.google.com">https://developer.google.com</a>":args[0]);<br></div><div>        System.out.println("Connect to " + url + " ...");<br></div><div><br></div><div>        HttpURLConnection.setFollowRedirects(false);</div><div>        HttpsURLConnection c = (HttpsURLConnection)url.openConnection();</div><div>        c.connect(); // throws SSL handshake exception<br></div><div>        System.out.println("Using " + c.getCipherSuite());</div><div><br></div><div>        System.out.println("-- iterate registered loggers");<br></div><div>        Enumeration<String> e = LogManager.getLogManager().getLoggerNames();<br></div><div>        while(e.hasMoreElements())</div><div>        {</div><div>            String n = e.nextElement();</div><div>            System.out.println("log " + n + " " + Logger.getLogger(n).getLevel());</div><div>        }</div><div>    }</div><div>}</div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div>