qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
824 stars 266 forks source link

SSL Handshake failed error when printing #1173

Closed Nightbringer01 closed 9 months ago

Nightbringer01 commented 10 months ago

I'm having issues using a https site with a local installation of QZ tray.

The application keeps returning SSL handshake failed. The connection works, but when I print anything it just throws the SSL handshake failed.

image

tresf commented 10 months ago

This is covered in part here: https://qz.io/docs/faq#pkix-build-path-failed

Java isn't really that great about using the system proxy, so workaround often includes fetching the resource using AJAX with the browser and sending it to QZ Tray using Base64 format.

Nightbringer01 commented 10 months ago

I'm not sure if I just haven't gone through the provided document enough, but I dont think the error I have is in the document.

It's a java.awt.print.PrinterException

here's a snippet of the log file:

[7.458s][info][class,load] sun.security.provider.certpath.SunCertPathBuilderException source: jrt:/java.base [7.458s][info][class,load] sun.security.provider.certpath.AdjacencyList source: jrt:/java.base [7.458s][info][class,load] sun.security.provider.certpath.BuildStep source: jrt:/java.base [7.458s][info][class,load] sun.security.validator.ValidatorException source: jrt:/java.base [7.458s][info][class,load] java.util.concurrent.ConcurrentLinkedQueue$Itr source: jrt:/java.base [7.458s][info][class,load] java.nio.BufferUnderflowException source: jrt:/java.base [7.459s][info][class,load] java.util.concurrent.ConcurrentLinkedQueue$$Lambda$831/0x00000008012236c8 source: java.util.concurrent.ConcurrentLinkedQueue [7.459s][info][class,load] jdk.internal.net.http.SocketTube$InternalWriteSubscriber$$Lambda$832/0x000000080121c028 source: jdk.internal.net.http.SocketTube [7.459s][info][class,load] jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription$$Lambda$833/0x000000080121c248 source: jdk.internal.net.http.SocketTube [7.460s][info][class,load] jdk.internal.net.http.ProxyAuthenticationRequired source: jrt:/java.net.http [7.460s][info][class,load] java.util.concurrent.ForkJoinPool$DefaultForkJoinWorkerThreadFactory$1 source: shared objects file [7.461s][info][class,load] com.sun.webkit.network.HTTP2Loader$$Lambda$834/0x00000008011e6b28 source: com.sun.webkit.network.HTTP2Loader [7.461s][info][class,load] com.sun.webkit.network.HTTP2Loader$$Lambda$835/0x00000008011e6d48 source: com.sun.webkit.network.HTTP2Loader [TRACE] 2023-09-10T23:26:37,329 @ qz.printer.action.html.WebApp:75 New state: RUNNING > FAILED [7.462s][info][class,load] org.apache.logging.log4j.core.impl.ThrowableProxy source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.462s][info][class,load] org.apache.logging.log4j.util.PrivateSecurityManagerStackTraceUtil source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.462s][info][class,load] org.apache.logging.log4j.util.PrivateSecurityManagerStackTraceUtil$PrivateSecurityManager source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.463s][info][class,load] org.apache.logging.log4j.core.impl.ThrowableProxyHelper source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.463s][info][class,load] org.apache.logging.log4j.core.impl.ExtendedStackTraceElement source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.463s][info][class,load] jdk.internal.loader.BootLoader$PackageHelper source: jrt:/java.base [7.463s][info][class,load] jdk.internal.loader.BootLoader$PackageHelper$$Lambda$836/0x0000000801223b10 source: jdk.internal.loader.BootLoader [7.463s][info][class,load] java.lang.ClassLoader$$Lambda$837/0x0000000801223d30 source: java.lang.ClassLoader [7.464s][info][class,load] org.apache.logging.log4j.core.impl.ThrowableProxyHelper$CacheEntry source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.464s][info][class,load] org.apache.logging.log4j.core.impl.ExtendedClassInfo source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.464s][info][class,load] org.apache.logging.log4j.core.impl.ThrowableProxyRenderer source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [ERROR] 2023-09-10T23:26:37,329 @ qz.utils.PrintingUtilities:214 Failed to print java.awt.print.PrinterException: SSL handshake failed at qz.printer.action.PrintHTML.print(PrintHTML.java:290) ~[qz-tray.jar:?] at qz.utils.PrintingUtilities.processPrintRequest(PrintingUtilities.java:204) ~[qz-tray.jar:?] at qz.ws.PrintSocketClient.processMessage(PrintSocketClient.java:301) ~[qz-tray.jar:?] at qz.ws.PrintSocketClient.onMessage(PrintSocketClient.java:167) ~[qz-tray.jar:?] at org.eclipse.jetty.websocket.core.internal.messages.DispatchedMessageSink.lambda$accept$0(DispatchedMessageSink.java:122) ~[qz-tray.jar:?] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969) ~[qz-tray.jar:?] at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194) ~[qz-tray.jar:?] at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149) ~[qz-tray.jar:?] at java.lang.Thread.run(Thread.java:832) ~[?:?] [TRACE] 2023-09-10T23:26:37,333 @ qz.utils.PrintingUtilities:170 Returning processor back to pool [7.465s][info][class,load] org.apache.commons.pool2.impl.LinkedBlockingDeque$Node source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [7.465s][info][class,load] org.apache.commons.pool2.impl.GenericKeyedObjectPool$$Lambda$838/0x0000000801228650 source: org.apache.commons.pool2.impl.GenericKeyedObjectPool [8.344s][info][class,load] org.eclipse.jetty.util.component.Graceful$$Lambda$839/0x0000000801228898 source: org.eclipse.jetty.util.component.Graceful [8.344s][info][class,load] org.eclipse.jetty.util.component.Graceful$$Lambda$840/0x0000000801228ad0 source: org.eclipse.jetty.util.component.Graceful [8.344s][info][class,load] org.eclipse.jetty.util.component.Graceful$ThrowingRunnable source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [8.344s][info][class,load] org.eclipse.jetty.websocket.common.SessionTracker$$Lambda$841/0x0000000801228ee0 source: org.eclipse.jetty.websocket.common.SessionTracker [8.344s][info][class,load] org.eclipse.jetty.util.component.Graceful$$Lambda$842/0x0000000801229100 source: org.eclipse.jetty.util.component.Graceful [8.345s][info][class,load] java.util.concurrent.CompletableFuture$Signaller source: jrt:/java.base [9.447s][info][class,load] jdk.internal.misc.Signal$1 source: jrt:/java.base [9.455s][info][class,load] com.sun.javafx.tk.quantum.QuantumRenderer$$Lambda$843/0x0000000801229320 source: com.sun.javafx.tk.quantum.QuantumRenderer [9.455s][info][class,load] com.sun.webkit.Disposer$DisposerRunnable source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [9.455s][info][class,load] com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$844/0x0000000801229760 source: com.sun.javafx.tk.quantum.QuantumToolkit [9.455s][info][class,load] com.sun.prism.impl.GlyphCache source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [9.462s][info][class,load] org.eclipse.jetty.io.WriteFlusher$1 source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [9.462s][info][class,load] org.eclipse.jetty.io.ManagedSelector$DestroyEndPoint source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [9.463s][info][class,load] org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession$$Lambda$845/0x000000080122a1f0 source: org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession [9.463s][info][class,load] org.eclipse.jetty.util.Callback$4 source: file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar [9.463s][info][class,load] org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession$$Lambda$846/0x000000080122a680 source: org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession [9.463s][info][class,load] org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession$$Lambda$847/0x000000080122a8a0 source: org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession [9.464s][info][class,load] org.eclipse.jetty.servlet.ServletHandler$$Lambda$848/0x000000080122aac0 source: org.eclipse.jetty.servlet.ServletHandler [9.464s][info][class,load] java.lang.invoke.LambdaForm$DMH/0x00000008011fc440 source: JVM_LookupDefineClass [9.464s][info][class,load] org.eclipse.jetty.servlet.ServletHandler$$Lambda$849/0x000000080122ad10 source: org.eclipse.jetty.servlet.ServletHandler [9.464s][info][class,load] java.lang.invoke.LambdaForm$MH/0x00000008011fb840 source: JVM_LookupDefineClass [9.464s][info][class,load] org.eclipse.jetty.servlet.ServletHandler$$Lambda$850/0x000000080122b118 source: org.eclipse.jetty.servlet.ServletHandler [9.464s][info][class,load] org.eclipse.jetty.servlet.ServletHandler$$Lambda$851/0x000000080122b368 source: org.eclipse.jetty.servlet.ServletHandler [INFO] 2023-09-10T23:26:39,331 @ qz.ws.PrintSocketClient:71 Connection closed: 1006 - Session Closed

tresf commented 10 months ago

@Nightbringer01 yeah you're right, this one is failing inside of JavaFX, but I believe the underlying cause is still certificate related.

- [ERROR] 2023-09-10T23:26:37,329 @ qz.utils.PrintingUtilities:214
- Failed to print
- java.awt.print.PrinterException: SSL handshake failed

... if you fetch the HTML content using $.ajax(...) or fetch(...) and use flavor: plain, I would expect this issue to go away. Of course, this can cause other issues (such as relative links breaking).

JavaFX should inherit the same certificates as Java, so the cause and resolution I would expect to be the same as mentioned, albeit surfacing as a different symptom.

Nightbringer01 commented 9 months ago

Yup the work around works, changed my code to this:

/// Pixel Printers ///
    function printHTML(html) {
        var config = getUpdatedConfig();

        var printData = [{
            type: 'pixel',
            format: 'html',
            flavor: 'plain',
            data: html,
        }];

        return qz.print(config, printData);
    }

    async function printURL(url) {
        var config = getUpdatedConfig();
        const response = await fetch(url);
        const htmldata = await response.text();

        return printHTML(htmldata);
    }