Skip to content

Instantly share code, notes, and snippets.

@md2perpe
Last active December 11, 2015 03:28
Show Gist options
  • Save md2perpe/4537790 to your computer and use it in GitHub Desktop.
Save md2perpe/4537790 to your computer and use it in GitHub Desktop.
<?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