Skip to content

Commit 9e95c33

Browse files
LuborRodRodion Liuborets
andauthored
Update phpseclib to 3.0 version (#259)
Co-authored-by: Rodion Liuborets <[email protected]>
1 parent c3a1be4 commit 9e95c33

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"php": "^7.1 || ^8.0",
1313
"ext-json": "*",
1414
"google/protobuf": "^3.10",
15-
"phpseclib/phpseclib": "^2.0",
15+
"phpseclib/phpseclib": "^3.0",
1616
"guzzlehttp/guzzle": "^6.4 || ^7.0",
1717
"psr/http-client": "^1.0",
1818
"psr/http-message": "^1.0",

src/Profile/Util/Attribute/AnchorConverter.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Yoti\Profile\Util\Attribute;
66

7-
use phpseclib\File\ASN1;
8-
use phpseclib\File\X509;
7+
use phpseclib3\File\ASN1;
8+
use phpseclib3\File\X509;
99
use Yoti\Profile\Attribute\Anchor;
1010
use Yoti\Profile\Attribute\SignedTimeStamp;
1111
use Yoti\Protobuf\Attrpubapi\Anchor as ProtobufAnchor;
@@ -58,10 +58,8 @@ public static function convert(ProtobufAnchor $protobufAnchor): Anchor
5858
*/
5959
private static function decodeAnchorValue(string $extEncodedValue): string
6060
{
61-
$X509 = new X509();
62-
$ASN1 = new ASN1();
63-
$encodedBER = $X509->_extractBER($extEncodedValue);
64-
$decodedValArr = $ASN1->decodeBER($encodedBER);
61+
$encodedBER = ASN1::extractBER($extEncodedValue);
62+
$decodedValArr = ASN1::decodeBER($encodedBER);
6563
if (isset($decodedValArr[0]['content'][0]['content'])) {
6664
return $decodedValArr[0]['content'][0]['content'];
6765
}
@@ -109,6 +107,14 @@ private static function convertCertToX509(string $certificate): \stdClass
109107
{
110108
$X509 = new X509();
111109
$X509Data = $X509->loadX509($certificate);
110+
111+
/** We need because of new 3.0 version phpseclib @link https://github.com/phpseclib/phpseclib/issues/1738 */
112+
array_walk_recursive($X509Data, function (&$item): void {
113+
if (is_string($item) && mb_detect_encoding($item) != 'ASCII') {
114+
$item = base64_encode($item);
115+
}
116+
});
117+
112118
$decodedX509Data = Json::decode(Json::encode($X509Data), false);
113119

114120
// Ensure serial number is cast to string.

0 commit comments

Comments
 (0)