From c3d7dad1370101ad255241e0d5ae88187b39e9aa Mon Sep 17 00:00:00 2001 From: amarnath-ayyadurai-23 Date: Mon, 18 Nov 2024 12:21:55 +0530 Subject: [PATCH 1/2] mtlsproxy updates --- includes/class-pantheoncurl.php | 8 ++++++-- includes/class-solrpower-api.php | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/includes/class-pantheoncurl.php b/includes/class-pantheoncurl.php index 248dd476..d7d365d6 100644 --- a/includes/class-pantheoncurl.php +++ b/includes/class-pantheoncurl.php @@ -23,8 +23,12 @@ public function createHandle( $request, $endpoint ) { $handler = parent::createHandle( $request, $endpoint ); if ( defined( 'PANTHEON_ENVIRONMENT' ) ) { curl_setopt( $handler, CURLOPT_SSL_VERIFYPEER, false ); - $client_cert = $_SERVER['HOME'] . '/certs/binding.pem'; - curl_setopt( $handler, CURLOPT_SSLCERT, $client_cert ); + if ( getenv('JOB_RUNTIME') !== "UJR" && getenv('MTLSPROXY_ENABLED') === 'true' ){ + curl_setopt( $handler, CURLOPT_SSL_VERIFYHOST, 0 ); + }else { + $client_cert = $_SERVER['HOME'] . '/certs/binding.pem'; + curl_setopt( $handler, CURLOPT_SSLCERT, $client_cert ); + } } return $handler; diff --git a/includes/class-solrpower-api.php b/includes/class-solrpower-api.php index 75edcc5e..9e22a36d 100644 --- a/includes/class-solrpower-api.php +++ b/includes/class-solrpower-api.php @@ -116,7 +116,7 @@ function submit_schema() { } $path = $this->compute_path(); - $url = $this->get_default_scheme() . '://' . getenv( 'PANTHEON_INDEX_HOST' ) . ':' . getenv( 'PANTHEON_INDEX_PORT' ) . $path; + $url = $this->get_default_scheme() . '://' . getenv( 'INDEX_PROXY_HOST' ) . ':' . getenv( 'INDEX_PROXY_PORT' ) . $path; $client_cert = self::get_cert_path(); /* @@ -139,7 +139,7 @@ function submit_schema() { // set URL and other appropriate options. $opts = array( CURLOPT_URL => $url, - CURLOPT_PORT => getenv( 'PANTHEON_INDEX_PORT' ), + CURLOPT_PORT => getenv( 'INDEX_PROXY_PORT' ), CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSLCERT => $client_cert, CURLOPT_SSL_VERIFYPEER => false, @@ -220,8 +220,8 @@ function get_solr() { $solarium_config = array( 'endpoint' => array( 'localhost' => array( - 'host' => getenv( 'PANTHEON_INDEX_HOST' ), - 'port' => getenv( 'PANTHEON_INDEX_PORT' ), + 'host' => getenv( 'INDEX_PROXY_HOST' ), + 'port' => getenv( 'INDEX_PROXY_PORT' ), 'scheme' => $this->get_default_scheme(), 'path' => $this->compute_path(), 'ssl' => array( @@ -605,8 +605,8 @@ public function get_server_info() { return array( 'ping_status' => $ping, - 'ip_address' => getenv( 'PANTHEON_INDEX_HOST' ), - 'port' => getenv( 'PANTHEON_INDEX_PORT' ), + 'ip_address' => getenv( 'INDEX_PROXY_HOST' ), + 'port' => getenv( 'INDEX_PROXY_PORT' ), 'path' => $this->compute_path(), ); From fc69a0a21f227222cc7dedf8c295b619e76ce9a9 Mon Sep 17 00:00:00 2001 From: amarnath-ayyadurai-23 Date: Mon, 18 Nov 2024 12:36:46 +0530 Subject: [PATCH 2/2] linting fixes #1 --- includes/class-pantheoncurl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/class-pantheoncurl.php b/includes/class-pantheoncurl.php index d7d365d6..332a6bd6 100644 --- a/includes/class-pantheoncurl.php +++ b/includes/class-pantheoncurl.php @@ -5,7 +5,7 @@ * @package Solr_Power */ -use Solarium\Core\Client\Adapter\Curl as Curl; +use Solarium\Core\Client\Adapter\Curl; /** * Override Solarium so that more options can be set before executing curl. @@ -23,9 +23,9 @@ public function createHandle( $request, $endpoint ) { $handler = parent::createHandle( $request, $endpoint ); if ( defined( 'PANTHEON_ENVIRONMENT' ) ) { curl_setopt( $handler, CURLOPT_SSL_VERIFYPEER, false ); - if ( getenv('JOB_RUNTIME') !== "UJR" && getenv('MTLSPROXY_ENABLED') === 'true' ){ + if ( getenv( 'JOB_RUNTIME' ) !== 'UJR' && getenv( 'MTLSPROXY_ENABLED' ) === 'true' ) { curl_setopt( $handler, CURLOPT_SSL_VERIFYHOST, 0 ); - }else { + } else { $client_cert = $_SERVER['HOME'] . '/certs/binding.pem'; curl_setopt( $handler, CURLOPT_SSLCERT, $client_cert ); }