-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #52093: openssl_csr_sign truncates $serial
We use `ASN1_INTEGER_set_int64()` if supported[1], to avoid the truncation of the integer. [1] <https://www.openssl.org/docs/man1.1.0/man3/ASN1_INTEGER_set_int64.html#HISTORY> Closes GH-7209.
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--TEST-- | ||
Bug #52093 (openssl_csr_sign truncates $serial) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("openssl")) print "skip"; | ||
if (PHP_INT_SIZE !== 8) die("skip this test is for 64bit platforms only"); | ||
?> | ||
--FILE-- | ||
<?php | ||
$dn = array( | ||
"countryName" => "BR", | ||
"stateOrProvinceName" => "Rio Grande do Sul", | ||
"localityName" => "Porto Alegre", | ||
"commonName" => "Henrique do N. Angelo", | ||
"emailAddress" => "hnangelo@php.net" | ||
); | ||
|
||
$privkey = openssl_pkey_new(); | ||
$csr = openssl_csr_new($dn, $privkey); | ||
$cert = openssl_csr_sign($csr, null, $privkey, 365, [], PHP_INT_MAX); | ||
var_dump(openssl_x509_parse($cert)['serialNumber']); | ||
?> | ||
--EXPECT-- | ||
string(19) "9223372036854775807" |