- Genera par de llaves RSA (cert en config/qz/) - api/qz_sign.php firma los print jobs con SHA512 - assets/js/qz-print.js conecta QZ Tray y envía trabajo HTML - ver_formulario_enviado.php carga QZ cuando ?autoprint=1 - Fallback a window.print() si QZ no está instalado Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
19 lines
644 B
PHP
19 lines
644 B
PHP
<?php
|
|
/**
|
|
* POST /api/qz_sign.php
|
|
* Firma el request de QZ Tray con la llave privada RSA del servidor.
|
|
* QZ Tray verifica la firma usando el digital-certificate.txt instalado en el cliente.
|
|
*/
|
|
header('Content-Type: text/plain');
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
$request = file_get_contents('php://input');
|
|
if (!$request) { http_response_code(400); exit('missing request'); }
|
|
|
|
$keyPath = __DIR__ . '/../config/qz/private-key.pem';
|
|
$key = openssl_pkey_get_private('file://' . $keyPath);
|
|
if (!$key) { http_response_code(500); exit('key error'); }
|
|
|
|
openssl_sign($request, $signature, $key, 'SHA512');
|
|
echo base64_encode($signature);
|