Skip to content

Commit

Permalink
Adjust some tests for whitespace differences in OpenSSL 3
Browse files Browse the repository at this point in the history
A trailing newline is no longer present in OpenSSL 3.
  • Loading branch information
nikic committed Aug 4, 2021
1 parent 3ea57cf commit 0a530d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
17 changes: 7 additions & 10 deletions ext/openssl/tests/bug28382.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ openssl
$cert = file_get_contents(__DIR__ . "/bug28382cert.txt");
$ext = openssl_x509_parse($cert);
var_dump($ext['extensions']);
/* openssl 1.0 prepends the string "Full Name:" to the crlDistributionPoints array key.
For now, as this is the one difference only between 0.9.x and 1.x, it's handled with
placeholders to not to duplicate the test. When more diffs come, a duplication would
be probably a better solution.
*/
/*
* The reason for %A at the end of crlDistributionPoints and authorityKeyIdentifier is that
* OpenSSL 3.0 removes new lines which were present in previous versions.
*/
?>
--EXPECTF--
array(11) {
Expand All @@ -22,18 +21,16 @@ array(11) {
["nsCertType"]=>
string(30) "SSL Client, SSL Server, S/MIME"
["crlDistributionPoints"]=>
string(%d) "%AURI:http://mobile.blue-software.ro:90/ca/crl.shtml
"
string(%d) "%AURI:http://mobile.blue-software.ro:90/ca/crl.shtml%A"
["nsCaPolicyUrl"]=>
string(38) "http://mobile.blue-software.ro:90/pub/"
["subjectAltName"]=>
string(28) "email:sergiu@bluesoftware.ro"
["subjectKeyIdentifier"]=>
string(59) "B0:A7:FF:F9:41:15:DE:23:39:BD:DD:31:0F:97:A0:B2:A2:74:E0:FC"
["authorityKeyIdentifier"]=>
string(115) "DirName:/C=RO/ST=Romania/L=Craiova/O=Sergiu/OU=Sergiu SRL/CN=Sergiu CA/emailAddress=n_sergiu@hotmail.com
serial:00
"
string(%d) "DirName:/C=RO/ST=Romania/L=Craiova/O=Sergiu/OU=Sergiu SRL/CN=Sergiu CA/emailAddress=n_sergiu@hotmail.com
serial:00%A"
["keyUsage"]=>
string(71) "Digital Signature, Non Repudiation, Key Encipherment, Data Encipherment"
["nsBaseUrl"]=>
Expand Down
5 changes: 2 additions & 3 deletions ext/openssl/tests/cve2013_4073.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ $info = openssl_x509_parse($cert);
var_export($info['extensions']);

?>
--EXPECT--
--EXPECTF--
array (
'basicConstraints' => 'CA:FALSE',
'subjectKeyIdentifier' => '88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C',
'keyUsage' => 'Digital Signature, Non Repudiation, Key Encipherment',
'subjectAltName' => 'DNS:altnull.python.org' . "\0" . 'example.com, email:null@python.org' . "\0" . 'user@example.org, URI:http://null.python.org' . "\0" . 'http://example.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1
',
'subjectAltName' => 'DNS:altnull.python.org' . "\0" . 'example.com, email:null@python.org' . "\0" . 'user@example.org, URI:http://null.python.org' . "\0" . 'http://example.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1%A',
)
10 changes: 4 additions & 6 deletions ext/openssl/tests/openssl_x509_parse_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ array(16) {
["subjectKeyIdentifier"]=>
string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D"
["authorityKeyIdentifier"]=>
string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D
string(%d) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D
DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net
serial:AE:C5:56:CC:72:37:50:A2
"
serial:AE:C5:56:CC:72:37:50:A2%A"
["basicConstraints"]=>
string(7) "CA:TRUE"
}
Expand Down Expand Up @@ -301,10 +300,9 @@ array(16) {
["subjectKeyIdentifier"]=>
string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D"
["authorityKeyIdentifier"]=>
string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D
string(%d) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D
DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net
serial:AE:C5:56:CC:72:37:50:A2
"
serial:AE:C5:56:CC:72:37:50:A2%A"
["basicConstraints"]=>
string(7) "CA:TRUE"
}
Expand Down

0 comments on commit 0a530d7

Please sign in to comment.