|
4 | 4 |
|
5 | 5 | namespace Yoti\Profile\Util\Attribute;
|
6 | 6 |
|
7 |
| -use phpseclib\File\ASN1; |
8 |
| -use phpseclib\File\X509; |
| 7 | +use phpseclib3\File\ASN1; |
| 8 | +use phpseclib3\File\X509; |
9 | 9 | use Yoti\Profile\Attribute\Anchor;
|
10 | 10 | use Yoti\Profile\Attribute\SignedTimeStamp;
|
11 | 11 | use Yoti\Protobuf\Attrpubapi\Anchor as ProtobufAnchor;
|
@@ -58,10 +58,8 @@ public static function convert(ProtobufAnchor $protobufAnchor): Anchor
|
58 | 58 | */
|
59 | 59 | private static function decodeAnchorValue(string $extEncodedValue): string
|
60 | 60 | {
|
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); |
65 | 63 | if (isset($decodedValArr[0]['content'][0]['content'])) {
|
66 | 64 | return $decodedValArr[0]['content'][0]['content'];
|
67 | 65 | }
|
@@ -109,6 +107,14 @@ private static function convertCertToX509(string $certificate): \stdClass
|
109 | 107 | {
|
110 | 108 | $X509 = new X509();
|
111 | 109 | $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 | + |
112 | 118 | $decodedX509Data = Json::decode(Json::encode($X509Data), false);
|
113 | 119 |
|
114 | 120 | // Ensure serial number is cast to string.
|
|
0 commit comments