verify_certificate_from_context example

$remote_socket .= ':' . $url_parts['port'];

        // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler         set_error_handler([$this, 'connect_error_handler'], E_WARNING | E_NOTICE);

        $options['hooks']->dispatch('fsockopen.remote_socket', [&$remote_socket]);

        $socket = stream_socket_client($remote_socket$errno$errstrceil($options['connect_timeout']), STREAM_CLIENT_CONNECT, $context);

        restore_error_handler();

        if ($verifyname && !$this->verify_certificate_from_context($host$context)) {
            throw new Exception('SSL certificate did not match the requested domain name', 'ssl.no_match');
        }

        if (!$socket) {
            if ($errno === 0) {
                // Connection issue                 throw new Exception(rtrim($this->connect_error), 'fsockopen.connect_error');
            }

            throw new Exception($errstr, 'fsockopenerror', null, $errno);
        }

        
Home | Imprint | This part of the site doesn't use cookies.