Skip to content

Instantly share code, notes, and snippets.

@webmaster128
Created March 4, 2015 11:53
Show Gist options
  • Select an option

  • Save webmaster128/a5622ee31b96665d9c5b to your computer and use it in GitHub Desktop.

Select an option

Save webmaster128/a5622ee31b96665d9c5b to your computer and use it in GitHub Desktop.
Create certificate validation hash
<?php
createDownload($_REQUEST['csr']);
function createDownload($csr_content)
{
# Write CSR content into csr.pem
file_put_contents("csr.pem", $csr_content)
or die("PEM file could not be written. Write permissions set?\n");
# Convert CSR from PEM to DER format
system("openssl req -outform der -in csr.pem -out csr.der", $error_code);
if ($error_code != 0) die("Error while converting PEM to DER file.\n");
# Generate hash content
$output = sha1_file("csr.der") . "\ncomodoca.com\n";
# Download resulting hash file
$filename = strtoupper(md5_file("csr.der")) . ".txt";
header("Content-Type: application/txt");
header('Content-Disposition: attachment; filename="' . $filename . "'");
echo $output;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment