Skip to content

Commit

Permalink
完善根证书解析方式
Browse files Browse the repository at this point in the history
  • Loading branch information
紫青 committed Sep 24, 2021
1 parent dbacbda commit 13fccdc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions php/src/Kernel/Util/AntCertificationUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getRootCertSN($certPath)
for ($i = 0; $i < count($array) - 1; $i++) {
$ssl[$i] = openssl_x509_parse($array[$i] . "-----END CERTIFICATE-----");
if (strpos($ssl[$i]['serialNumber'], '0x') === 0) {
$ssl[$i]['serialNumber'] = $this->hex2dec($ssl[$i]['serialNumber']);
$ssl[$i]['serialNumber'] = $this->hex2dec($ssl[$i]['serialNumberHex']);
}
if ($ssl[$i]['signatureTypeLN'] == "sha1WithRSAEncryption" || $ssl[$i]['signatureTypeLN'] == "sha256WithRSAEncryption") {
if ($SN == null) {
Expand All @@ -72,7 +72,7 @@ function hex2dec($hex)
{
$dec = 0;
$len = strlen($hex);
for ($i = (false === strpos(strtolower($hex), '0x') ? 1 : 3); $i <= $len; $i++) {
for ($i = 1; $i <= $len; $i++) {
$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
}
return $dec;
Expand Down Expand Up @@ -609,4 +609,4 @@ function stripSignerAsn($der = null)
}
return substr($der, 4, $len + 4);
}
}
}

0 comments on commit 13fccdc

Please sign in to comment.