Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Try do decode OcspBasicResponse nonce extension
Browse files Browse the repository at this point in the history
WE2-879

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored and mrts committed Mar 8, 2024
1 parent e6dcd89 commit 3a35a0c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/OcspBasicResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public function getCertificates(): array
foreach ($this->ocspBasicResponse["certs"] as $cert) {
$x509 = new X509();
/*
We need to DER encode each responder certificate array as there exists some
more loading in X509->loadX509 method, which is not executed when loading just basic array.
For example without this the publicKey would not be in PEM format and X509->getPublicKey()
will throw error. It also maps out the extensions from BIT STRING
*/
We need to DER encode each responder certificate array as there exists some
more loading in X509->loadX509 method, which is not executed when loading just basic array.
For example without this the publicKey would not be in PEM format and X509->getPublicKey()
will throw error. It also maps out the extensions from BIT STRING
*/
$x509->loadX509(ASN1::encodeDER($cert, Certificate::MAP));
$certificatesArr[] = $x509;
}
Expand Down Expand Up @@ -130,7 +130,12 @@ function ($extension) {
);

if (isset($filter[0]["extnValue"])) {
return $filter[0]["extnValue"];
$decoded = ASN1::decodeBER($filter[0]["extnValue"]);
if(is_array($decoded)) {
return ASN1::asn1map($decoded[0], ['type' => ASN1::TYPE_OCTET_STRING]);
} else {
return $filter[0]["extnValue"];
}
}

return null;
Expand Down

0 comments on commit 3a35a0c

Please sign in to comment.