Hello everyone, I'm using the demo certificate and I'm getting this error below. I'll post all the information I can for you to help me:
Ambient Linux Ubuntu


Route sing PHP:
try {
$dataToSign = $request->input('data');
if (!$dataToSign) {
abort(400, 'Dados ausentes para assinatura.');
}
$privateKeyPath = storage_path('app/keys/private-key.pem');
if (!file_exists($privateKeyPath)) {
abort(500, 'Chave privada não encontrada.');
}
$privateKeyContent = file_get_contents($privateKeyPath);
// Carrega a chave de forma segura com openssl_get_privatekey
$privateKey = openssl_get_privatekey($privateKeyContent);
if (!$privateKey) {
abort(500, 'Erro ao carregar a chave privada.');
}
$signature = null;
$success = openssl_sign($dataToSign, $signature, $privateKey, OPENSSL_ALGO_SHA512);
openssl_free_key($privateKey);
if (!$success || !$signature) {
abort(500, 'Erro ao assinar os dados.');
}
return base64_encode($signature);
} catch (Throwable $exception) {
throw new AppException(
message: __('payment::exceptions.payment.error_found'),
previous: $exception
);
}
}JS:
const handlePrint = async () => {
qz.websocket
.connect()
.then(() => {
console.log(qz.printers.find());
return qz.printers.find("PDF");
})
.then((found) => {
const config = qz.configs.create(found);
const cliente = {
nome: "João da Silva",
cpf: "123.456.789-00",
pagamento: "Cartão de crédito",
valor: 150.75,
data: new Date().toLocaleString("pt-BR"),
pedido: "Pedido #12345",
};
const data = [
{
type: "pixel",
format: "html",
flavor: "plain",
data: `
<div style="width: 260px; margin: 0 auto; font-family: monospace; font-size: 12px; padding-left: 10px;">
<center>
<h2 style="margin: 0;">Cota Fácil</h2>
<p style="margin: 0;">CNPJ: 12.345.678/0001-90</p>
<p style="margin: 0;">Rua Exemplo, 123 - Cidade/UF</p>
<hr style="margin: 5px 0;" />
<strong>COMPROVANTE DE PAGAMENTO</strong>
<hr style="margin: 5px 0;" />
</center>
<p><strong>Tipo de Fatura:</strong> Boleto Detran</p>
<p><strong>Nome:</strong> João da Silva</p>
<p><strong>CPF:</strong> 080.387.309-33</p>
<p><strong>Valor:</strong> R$ 155,81</p>
<p><strong>Tipo de Pagamento:</strong> Cartão de crédito</p>
<p><strong>Data:</strong> 03/06/2025</p>
<p><strong>Protocolo:</strong> 1234</p>
<hr style="margin: 5px 0;" />
<center>
<p>Obrigado pela preferência!</p>
<p>--- Cota Fácil ---</p>
</center>
</div>
`,
},
];
return qz.print(config, data);
})
.catch((err) => {
console.error("Erro ao imprimir", err);
})
.finally(() => {
console.log("Impressão finalizada");
return qz.websocket.disconnect();
});
};
const signature = () => {
qz.security.setCertificatePromise((resolve, reject) => {
resolve(certificateDemo);
});
qz.security.setSignatureAlgorithm("SHA512");
qz.security.setSignaturePromise((toSign: string) => {
return api
.post("/payments/sign", { data: toSign })
.then((response: any) => {
console.log("Resposta sign: ", response.data);
return response.data;
})
.catch((error: any) => {
console.error("Erro ao assinar:", error);
throw new Error("Erro ao assinar a requisição.");
});
});
console.log("Certificado e assinatura configurados.");
};From the QZ Tray Icon:
Advanced, Troubleshooting, Zip Logs (To Desktop)
--
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+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/qz-print/CAMvs40MTcJz7yJj53FU2FScw7808HAF2Zi6SZPOTmS%2B%2Bg_3X6Q%40mail.gmail.com.
Error: Failed to sign request at http://terminal.cotafacil.local:5173/node_modules/...
To view this discussion visit https://groups.google.com/d/msgid/qz-print/CAPnxpeBqE0oAvzupgcHqCZ%3Df%3DXWhc4NJ9CVzyTuzB%2BoW%2B4xMhw%40mail.gmail.com.