Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,31 @@ private function getCertificateIssuerName()
*/
private function getCertificateIssuerSerialNumber()
{
// 1.) We need to use serialNumberHex since serialNumber is not to be trusted
// Pls. see last comment on https://bugs.php.net/bug.php?id=77411&edit=1

// 2.) Some (new?) FISKAL_2 certificates have serial number which exceeds int32 limit

$publicCertData = $this->getPublicCertificateData();
return $this->bchexdec($publicCertData['serialNumberHex']);
}

return $publicCertData['serialNumber'];
/**
* Convert "big" hex to string representing integers which exceeds int32 limit
* see getCertificateIssuerSerialNumber()
* https://stackoverflow.com/questions/1273484/large-hex-values-with-php-hexdec
*
* @param string $hex
* @return string
*/
public function bchexdec($hex)
{
$dec = 0;
$len = strlen($hex);
for ($i = 1; $i <= $len; $i++) {
$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
}
return $dec;
}

/**
Expand Down