Requests_Transport_fsockopen::verify_certificate_from_context() WordPress Method

The Requests_Transport_fsockopen::verify_certificate_from_context() function provides a way to verify a SSL certificate from a context. This is useful when you need to verify a certificate that is not in the standard bundle, or when you need to provide extra context options for the verification process.

Requests_Transport_fsockopen::verify_certificate_from_context( string $host, resource $context ) #

Verify the certificate against common name and subject alternative names


Description

Unfortunately, PHP doesn’t check the certificate against the alternative names, leading things like ‘https://www.github.com/‘ to be invalid. Instead

Top ↑

See also


Top ↑

Parameters

$host

(string)(Required)Host name to verify against

$context

(resource)(Required)Stream context


Top ↑

Return

(bool)


Top ↑

Source

File: wp-includes/Requests/Transport/fsockopen.php

	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 Requests_Exception(rtrim($this->connect_error), 'ssl.connect_error');
		}

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

		return Requests_SSL::verify_certificate($host, $cert);
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.