Skip to content

Instantly share code, notes, and snippets.

@ConConovaloff
Created September 4, 2015 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ConConovaloff/b41a513ef27696b86ef3 to your computer and use it in GitHub Desktop.
Save ConConovaloff/b41a513ef27696b86ef3 to your computer and use it in GitHub Desktop.
Self-signed certificate
$domain = 'conovaloff.com';
$configParams = [
"private_key_bits" => 2048,
'private_key_type' => OPENSSL_KEYTYPE_RSA
];
$privkey = openssl_pkey_new($configParams);
$data = array(
"countryName" => "RU",
"stateOrProvinceName" => "Moscow",
"localityName" => "Moscow",
"organizationName" => "Company",
"organizationalUnitName" => "Development",
"commonName" => $domain,
"emailAddress" => "admin@" . $domain
);
$csr = openssl_csr_new($data, $privkey, $configParams);
$sscert = openssl_csr_sign($csr, null, $privkey, $duration, $configParams);
openssl_x509_export($sscert, $certout);
openssl_pkey_export($privkey, $pkout, $password, $configParams);
var_dump($certout);
var_dump($pkout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment