diff --git a/src/Symfony/Component/VarDumper/Caster/ConstStub.php b/src/Symfony/Component/VarDumper/Caster/ConstStub.php index 250a250a9f7c4..15868b0934219 100644 --- a/src/Symfony/Component/VarDumper/Caster/ConstStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ConstStub.php @@ -20,10 +20,10 @@ */ class ConstStub extends Stub { - public function __construct(string $name, $value) + public function __construct(string $name, $value = null) { $this->class = $name; - $this->value = $value; + $this->value = 1 < \func_num_args() ? $value : $name; } public function __toString() diff --git a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php index 3cdb27c30879b..85de5b59674ac 100644 --- a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php @@ -69,4 +69,30 @@ public static function castMysqlLink($h, array $a, Stub $stub, $isNested) return $a; } + + public static function castOpensslX509($h, array $a, Stub $stub, $isNested) + { + $stub->cut = -1; + $info = openssl_x509_parse($h, false); + + $pin = openssl_pkey_get_public($h); + $pin = openssl_pkey_get_details($pin)['key']; + $pin = \array_slice(explode("\n", $pin), 1, -2); + $pin = base64_decode(implode('', $pin)); + $pin = base64_encode(hash('sha256', $pin, true)); + + $a += array( + 'subject' => new EnumStub(array_intersect_key($info['subject'], array('organizationName' => true, 'commonName' => true))), + 'issuer' => new EnumStub(array_intersect_key($info['issuer'], array('organizationName' => true, 'commonName' => true))), + 'expiry' => new ConstStub(date(\DateTime::ISO8601, $info['validTo_time_t']), $info['validTo_time_t']), + 'fingerprint' => new EnumStub(array( + 'md5' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'md5')), 2, ':', true)), + 'sha1' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha1')), 2, ':', true)), + 'sha256' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha256')), 2, ':', true)), + 'pin-sha256' => new ConstStub($pin), + )), + ); + + return $a; + } } diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 88691609e1906..f55b2a1c67c00 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -136,6 +136,7 @@ abstract class AbstractCloner implements ClonerInterface ':pgsql result' => array('Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castResult'), ':process' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castProcess'), ':stream' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'), + ':OpenSSL X.509' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castOpensslX509'), ':persistent stream' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'), ':stream-context' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStreamContext'), ':xml' => array('Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'), @@ -176,7 +177,7 @@ public function __construct(array $casters = null) public function addCasters(array $casters) { foreach ($casters as $type => $callback) { - $closure = &$this->casters[strtolower($type)][]; + $closure = &$this->casters['' === $type || ':' === $type[0] ? $type : strtolower($type)][]; $closure = $callback instanceof \Closure ? $callback : static function (...$args) use ($callback, &$closure) { return ($closure = \Closure::fromCallable($callback))(...$args); };
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: