diff --git a/src/Profile/Util/Attribute/AnchorConverter.php b/src/Profile/Util/Attribute/AnchorConverter.php index 89558202..3f919df9 100644 --- a/src/Profile/Util/Attribute/AnchorConverter.php +++ b/src/Profile/Util/Attribute/AnchorConverter.php @@ -115,8 +115,8 @@ private static function convertCertToX509(string $certificate): \stdClass } }); - $decodedX509Data = Json::decode(Json::encode($X509Data), false); - + //$decodedX509Data = Json::decode(Json::encode($X509Data), false); + $decodedX509Data = Json::decode(Json::encode(Json::convert_from_latin1_to_utf8_recursively($X509Data)), false); // Ensure serial number is cast to string. // @see \phpseclib\Math\BigInteger::__toString() $decodedX509Data diff --git a/src/Util/Json.php b/src/Util/Json.php index cdeeefd9..e014e174 100644 --- a/src/Util/Json.php +++ b/src/Util/Json.php @@ -55,4 +55,22 @@ private static function validate(): void throw new JsonException(json_last_error_msg(), json_last_error()); } } + + public static function convert_from_latin1_to_utf8_recursively($dat) + { + if (is_string($dat)) { + return utf8_encode($dat); + } elseif (is_array($dat)) { + $ret = []; + foreach ($dat as $i => $d) $ret[ $i ] = self::convert_from_latin1_to_utf8_recursively($d); + + return $ret; + } elseif (is_object($dat)) { + foreach ($dat as $i => $d) $dat->$i = self::convert_from_latin1_to_utf8_recursively($d); + + return $dat; + } else { + return $dat; + } + } }