Using my own certificate to avoid prompt in QZ-Tray

1,802 views
Skip to first unread message

nbag...@gmail.com

unread,
May 2, 2017, 1:39:07 PM5/2/17
to qz-print
Hi

I am trying to use my own trusted Certificate but it seems i can't load it

1. Here is code:

<script type="text/javascript">

qz.security.setCertificatePromise(function(resolve, reject) {
//Preferred method - from server
$.ajax("qz20/nmbm_bundle.crt").then(resolve, reject);
});

qz.security.setSignaturePromise(function(toSign) {
return function(resolve, reject) {
//Preferred method - from server
$.ajax("sign-message.php?request=" + toSign).then(resolve, reject);
};
});


qz.websocket.connect().then(function() {
return qz.printers.find("Talao") // Pass the printer name into the next Promise
}).then(function(printer) {
var config = qz.configs.create(printer); // Create a default config for the found printer
var data = [{type: 'raw', data: '<?php echo $POSPrint;?>'}]; // Raw ZPL
return qz.print(config, data);
}).catch(function(e) { console.error(e); });

</script>


2. The certifcate conntent (can i upload it?)



3. Here's the result in console:

[INFO] 2017-05-02 18:37:20,364 @ qz.ws.PrintSocketClient:?
Connection opened from /0:0:0:0:0:0:0:1:58916 on socket port 8182
[DEBUG] 2017-05-02 18:37:20,411 @ qz.ws.PrintSocketClient:?
Message: {"certificate":{"description":"'$' nï¿£o estï¿¡ definido","number":-2146823279,"stack":"ReferenceError: '$' nï¿£o estï¿¡ definido\n at Anonymous function (http://dev.nmbm.biz/npos/LAB-pos_print.php?mc_id=27:37:5)\n at lib$rsvp$$internal$$initializePromise (http://dev.nmbm.biz/npos/qz20/dependencies/rsvp-3.1.0.min.js:10:9164)\n at lib$rsvp$promise$$Promise (http://dev.nmbm.biz/npos/qz20/dependencies/rsvp-3.1.0.min.js:10:14801)\n at _qz.tools.promise (http://dev.nmbm.biz/npos/qz20/qz-tray.js:442:17)\n at _qz.security.callCert (http://dev.nmbm.biz/npos/qz20/qz-tray.js:427:17)\n at _qz.websocket.setup.openConnection (http://dev.nmbm.biz/npos/qz20/qz-tray.js:289:21)\n at _qz.websocket.connection.onopen (http://dev.nmbm.biz/npos/qz20/qz-tray.js:122:29)"},"promise":{},"timestamp":1493746640412,"uid":"3ri2ym"}
[INFO] 2017-05-02 18:37:36,991 @ qz.common.TrayManager:?
Allowed An anonymous request to connect to QZ


Thank you for your help

Tres Finocchiaro

unread,
May 2, 2017, 2:04:24 PM5/2/17
to nbag...@gmail.com, qz-print
Your certificate must be in a base64 encoded format or strange things will happen.

--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tres Finocchiaro

unread,
May 2, 2017, 2:05:17 PM5/2/17
to nbag...@gmail.com, qz-print
 (can i upload it?)

Only if it's a pure certificate.  If it's a p12 or pfx and has a private key embedded, never (ever) upload it. ;) 

nbag...@gmail.com

unread,
May 2, 2017, 2:43:07 PM5/2/17
to qz-print, nbag...@gmail.com
> To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



Thank you Tres, for your help


The certificate is the same i use for https support on my site

the CSR was generated like this:

$ openssl req -out CSR.csr -key private.key -new -sha256

Tres Finocchiaro

unread,
May 2, 2017, 3:33:13 PM5/2/17
to nbag...@gmail.com, qz-print
I'm sorry, I mistook "$' nï¿£o estï¿¡ definido" for something else.

"$ is not defined" means you do not have jQuery included properly.  Can you please try that?


To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+unsubscribe@googlegroups.com.

nbag...@gmail.com

unread,
May 2, 2017, 4:27:48 PM5/2/17
to qz-print, nbag...@gmail.com
of course...

in fact I tought it was included, but it wasn't. Now I fixed it and it can read the certificate. However, it still asks for permission.

The log is very large... how can i upload it?

nbag...@gmail.com

unread,
May 2, 2017, 4:29:51 PM5/2/17
to qz-print, nbag...@gmail.com
also have info about certificate

Organization Unknown
Common Name An anonymous request
Trusted false
Valid From 0002-11-30 00:00:00
Valid To 0002-11-30 00:00:00
Fingerprint UNKNOWN REQUEST



Tres Finocchiaro

unread,
May 2, 2017, 4:45:16 PM5/2/17
to nbag...@gmail.com, qz-print
By default, our software does not trust standard SSL certificates, additional steps are needed to shim in a 3rd party certificate as trusted into our software.  These steps are in the advanced section of our signing messages tutorial.



To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+unsubscribe@googlegroups.com.

nbag...@gmail.com

unread,
May 2, 2017, 8:24:23 PM5/2/17
to qz-print, nbag...@gmail.com
I've tried your untrusted certificate that came with sample.html and it could make a proper reading, wich leads me to the conclusion that my trusted certificate is innapropriate for this, as you said.

Thank you for your help understanding this

i am considering buy your certificate
Reply all
Reply to author
Forward
0 new messages