WP_CLI\Utils

get_default_cacert()WP-CLI 1.0

Gets the full path to the default CA cert.

No Hooks.

Returns

String. Absolute path to the default CA cert.

Usage

get_default_cacert( $halt_on_error );
$halt_on_error(true|false)
Whether or not command execution should be halted on error. Default: false.
Default: false

get_default_cacert() code WP-CLI 2.13.0-alpha

function get_default_cacert( $halt_on_error = false ) {
	$cert_path = RequestsLibrary::get_bundled_certificate_path();
	$error_msg = 'Cannot find SSL certificate.';

	if ( inside_phar( $cert_path ) ) {
		// cURL can't read Phar archives.
		return extract_from_phar( $cert_path );
	}

	if ( file_exists( $cert_path ) ) {
		return $cert_path;
	}

	if ( $halt_on_error ) {
		WP_CLI::error( $error_msg );
	}

	throw new RuntimeException( $error_msg );
}