Last active
December 11, 2015 03:28
-
-
Save md2perpe/4537790 to your computer and use it in GitHub Desktop.
Part of a file from http://webcodingeasy.com/PHP-Security/Managing-X509-certificates-using-PHP
This file contains hidden or 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 | |
// Returns a cer encoded SSL certificate | |
function create_identity_cer( | |
$countryName, $stateOrProvinceName, $localityName, $organizationName, | |
$organizationalUnitName, $commonName, $emailAddress, $foafLocation) | |
{ | |
// Create the DN array for the openssl function calls | |
$fields = array( | |
'countryName', | |
'stateOrProvinceName', | |
'localityName', | |
'organizationName', | |
'organizationalUnitName', | |
'commonName', | |
'emailAddress', | |
); | |
$dn = array(); | |
foreach ($fields as $f) | |
{ | |
if (${$f}) | |
$dn[$f] = ${$f}; | |
} | |
// if the $dn array is NULL at this point set country name to the default of GB | |
if (empty($dn)) | |
$dn = array("countryName" => "GB"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment