Skip to content

Instantly share code, notes, and snippets.

@pkdavies
Created April 9, 2013 09:00
Show Gist options
  • Save pkdavies/5344198 to your computer and use it in GitHub Desktop.
Save pkdavies/5344198 to your computer and use it in GitHub Desktop.
Check CSR Details
<h3>Check CSR Details</h3>
<form method="post">
<p>Paste the CSR in the text area below:</p>
<textarea rows="16" cols="65" name="csr">
</textarea>
<br />
<input type="submit" />
</form>
<hr noshade />
<?php
if (isset($_POST['csr']) && strlen($_POST['csr'])){
$csr = $_POST['csr'];
$csr_detail = openssl_csr_get_subject($csr);
if (is_array($csr_detail)){
echo "<h3>CSR Results</h3><ul>";
foreach ($csr_detail as $key => $value) {
switch ($key) {
case "C": $key = "Country"; break;
case "L": $key = "Location"; break;
case "O": $key = "Organisation"; break;
case "CN": $key = "Common Name"; break;
default: break;
}
echo "<li>".$key." = ".$value."</li>";
}
echo "</ul>";
}
} else {
echo "No CSR detail submitted.";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment