Created
April 1, 2022 03:27
Using certificates in qz tray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Access-Control-Allow-Origin: *'); | |
header("Access-Control-Allow-Headers: Origin, Cookie, Accept-Language, Cache-Control, X-Requested-With, Content-Type, Accept, Authorization, X-Api-Key"); | |
header("Access-Control-Allow-Methods: GET, PUT, POST, DELETE, PATCH, OPTIONS"); | |
header("Access-Control-Allow-Credentials: true"); | |
if (!empty($_SERVER["REQUEST_METHOD"]) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') { | |
exit(); | |
} | |
$KEY = 'private-key.pem'; | |
$req = $_POST['request']; | |
$privateKey = openssl_get_privatekey(file_get_contents($KEY)); | |
$signature = null; | |
openssl_sign($req, $signature, $privateKey, "sha1"); | |
if ($signature) { | |
header("Content-type: text/plain"); | |
echo base64_encode($signature); | |
exit(0); | |
} | |
echo '<h1>Error signing message</h1>'; | |
http_response_code(500); | |
exit(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment