note 111062 added to ref.openssl

From: Date: Thu, 10 Jan 2013 18:35:25 +0000
Subject: note 111062 added to ref.openssl
Groups: php.notes 
Request: Send a blank email to php-notes+get-192891@lists.php.net to get a copy of this message
If you want to verify that a csr was generated properly from your private key you can do the following: <?php $countryName = "UK"; $stateOrProvinceName = "London"; $localityName = "Blah"; $organizationName = "Blah1"; $organizationalUnitName = "Blah2"; $commonName = "Joe Bloggs"; $emailAddress = "openssl@domain.com"; $dn = array( "countryName" => $countryName, "stateOrProvinceName" => $stateOrProvinceName, "localityName" => $localityName, "organizationName" => $organizationName, "organizationalUnitName" => $organizationalUnitName, "commonName" => $commonName, "emailAddress" => $emailAddress ); $badPriv = 'foo'; // generate a bad csr $badCsr = openssl_csr_new($dn, $badPriv); // generate private key $priv = openssl_pkey_new(); // generate csr $csr = openssl_csr_new($dn, $priv); $badCsrDetails = openssl_pkey_get_details(openssl_csr_get_public_key($badCsr)); $privDetails = openssl_pkey_get_details($priv); $csrDetails = openssl_pkey_get_details(openssl_csr_get_public_key($csr)); echo md5($badCsrDetails['rsa']['n']); echo "\nDoes not match\n"; echo md5($privDetails['rsa']['n']); echo "\nMatches\n"; echo md5($csrDetails['rsa']['n']); echo "\n"; ?> This output is an md5 hash of the modulus. The same check can be accomplished with openssl: openssl rsa -noout -modulus -in server.key | openssl md5 openssl req -noout -modulus -in server.csr | openssl md5 ---- Server IP: 69.147.83.199 Probable Submitter: 96.226.117.224 ---- Manual Page -- http://php.net/manual/en/ref.openssl.php Edit -- https://master.php.net/note/edit/111062 Del: integrated -- https://master.php.net/note/delete/111062/integrated Del: useless -- https://master.php.net/note/delete/111062/useless Del: bad code -- https://master.php.net/note/delete/111062/bad+code Del: spam -- https://master.php.net/note/delete/111062/spam Del: non-english -- https://master.php.net/note/delete/111062/non-english Del: in docs -- https://master.php.net/note/delete/111062/in+docs Del: other reasons-- https://master.php.net/note/delete/111062 Reject -- https://master.php.net/note/reject/111062 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192891) next »