forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug #80269: OpenSSL sets Subject wrong with extraattribs parameter
Closes phpGH-12979
- Loading branch information
Showing
6 changed files
with
138 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
oid_section = new_oids | ||
[ new_oids ] | ||
aansluitNummer = 1.3.6.1.4.1.11278.1150.2.1 | ||
kvkNummer = 1.3.6.1.4.1.11278.1150.2.2 | ||
|
||
[ req ] | ||
default_bits = 2048 | ||
distinguished_name = req_distinguished_name | ||
attributes = req_attributes | ||
req_extensions = v3_req | ||
prompt = no | ||
|
||
[ req_distinguished_name ] | ||
C = NL | ||
ST = ST | ||
L = L | ||
O = O | ||
CN = test | ||
|
||
[ req_attributes ] | ||
facsimileTelephoneNumber = | ||
postalCode = | ||
streetAddress = | ||
name = Organisation | ||
telephoneNumber = 012345678 | ||
aansluitNummer = 1234 | ||
kvkNummer = 12345678 | ||
emailAddress = [email protected] | ||
|
||
[ v3_req ] | ||
basicConstraints = CA:FALSE |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--TEST-- | ||
openssl_csr_new() attributes setting tests | ||
--EXTENSIONS-- | ||
openssl | ||
--FILE-- | ||
<?php | ||
|
||
$dn = array( | ||
"countryName" => "UK", | ||
"stateOrProvinceName" => "England", | ||
"localityName" => "London", | ||
"commonName" => "test.php.net", | ||
"emailAddress" => "[email protected]" | ||
); | ||
|
||
|
||
$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl_csr_attribs.cnf'; | ||
|
||
$config_arg = array('config' => $config); | ||
|
||
$args = array( | ||
"digest_alg" => "sha256", | ||
"private_key_bits" => 2048, | ||
"private_key_type" => OPENSSL_KEYTYPE_DSA, | ||
"encrypt_key" => true, | ||
"config" => $config, | ||
); | ||
|
||
$privkey = 'file://' . __DIR__ . '/private_rsa_2048.key'; | ||
|
||
$csr = openssl_csr_new( | ||
$dn, | ||
$privkey, | ||
$args, | ||
[ | ||
'emailAddress' => '[email protected]', | ||
'aansluitNummer' => '11112222', | ||
'postalCode' => 'N11', | ||
] | ||
); | ||
|
||
|
||
var_dump(openssl_csr_get_subject($csr)); | ||
var_dump(openssl_csr_export($csr, $output)); | ||
var_dump($output); | ||
|
||
var_dump(openssl_csr_new( | ||
$dn, | ||
$privkey, | ||
$args, | ||
['wrong' => '[email protected]'] | ||
)); | ||
|
||
?> | ||
--EXPECTF-- | ||
array(5) { | ||
["C"]=> | ||
string(2) "UK" | ||
["ST"]=> | ||
string(7) "England" | ||
["L"]=> | ||
string(6) "London" | ||
["CN"]=> | ||
string(12) "test.php.net" | ||
["emailAddress"]=> | ||
string(16) "[email protected]" | ||
} | ||
bool(true) | ||
string(1269) "-----BEGIN CERTIFICATE REQUEST----- | ||
MIIDcDCCAlgCAQAwaDELMAkGA1UEBhMCVUsxEDAOBgNVBAgMB0VuZ2xhbmQxDzAN | ||
BgNVBAcMBkxvbmRvbjEVMBMGA1UEAwwMdGVz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GAwIgOv8XPUQGem52yMEvzySRC4ZyTddfiZAkeTLmbh+SMVbHXXOk | ||
UeEz+fvmQ4L+sc3RE8u+M8g31LM= | ||
-----END CERTIFICATE REQUEST----- | ||
" | ||
|
||
Warning: openssl_csr_new(): attributes: wrong is not a recognized attribute name in %s on line %d | ||
object(OpenSSLCertificateSigningRequest)#%d (0) { | ||
} |