openssl_x509_parse example


    public static function verify_ssl_certificate( $stream$host ) {
        $context_options = stream_context_get_options( $stream );

        if ( empty( $context_options['ssl']['peer_certificate'] ) ) {
            return false;
        }

        $cert = openssl_x509_parse( $context_options['ssl']['peer_certificate'] );
        if ( ! $cert ) {
            return false;
        }

        /* * If the request is being made to an IP address, we'll validate against IP fields * in the cert (if they exist) */
        $host_type = ( WP_Http::is_ip_address( $host ) ? 'ip' : 'dns' );

        $certificate_hostnames = array();
        

    public function verify_certificate_from_context($host$context) {
        $meta = stream_context_get_options($context);

        // If we don't have SSL options, then we couldn't make the connection at         // all         if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate'])) {
            throw new Exception(rtrim($this->connect_error), 'ssl.connect_error');
        }

        $cert = openssl_x509_parse($meta['ssl']['peer_certificate']);

        return Ssl::verify_certificate($host$cert);
    }

    /** * Self-test whether the transport can be used. * * The available capabilities to test for can be found in {@see \WpOrg\Requests\Capability}. * * @codeCoverageIgnore * @param array<string, bool> $capabilities Optional. Associative array of capabilities to test against, i.e. `['<capability>' => true]`. * @return bool Whether the transport can be used. */
$a['trueColor'] = imageistruecolor($gd);

        return $a;
    }

    /** * @return array */
    public static function castOpensslX509($h, array $a, Stub $stub, bool $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 += [
            'subject' => new EnumStub(array_intersect_key($info['subject']['organizationName' => true, 'commonName' => true])),
            'issuer' => new EnumStub(array_intersect_key($info['issuer']['organizationName' => true, 'commonName' => true])),
            'expiry' => new ConstStub(date(\DateTimeInterface::ISO8601, $info['validTo_time_t'])$info['validTo_time_t']),
            
$a['trueColor'] = imageistruecolor($gd);

        return $a;
    }

    /** * @return array */
    public static function castOpensslX509($h, array $a, Stub $stub, bool $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 += [
            'subject' => new EnumStub(array_intersect_key($info['subject']['organizationName' => true, 'commonName' => true])),
            'issuer' => new EnumStub(array_intersect_key($info['issuer']['organizationName' => true, 'commonName' => true])),
            'expiry' => new ConstStub(date(\DateTimeInterface::ISO8601, $info['validTo_time_t'])$info['validTo_time_t']),
            
Home | Imprint | This part of the site doesn't use cookies.