Zend certified PHP/Magento developer

Soap verify_pear = true gets failed

I have installed the OpenSSL 1.1 and Lets Encrypt SSL on a Magento installation. I am trying to connect the Fedex Service on Magento. Whenever it tries to fetch the rate I am getting an error Unable to connect.

After debugging I found that it is using Soap Service to connect to https://wsbeta.fedex.com:443/web-services. from <magento_root_directory>/vendor/magento/module-fedex/Model/Carrier.php at line ~ #248 (in method _createSoapClient ).

protected function _createSoapClient($wsdl, $trace = false)
{
    $client = $this->soapClientFactory->create($wsdl, ['trace' => $trace]);
    $client->__setLocation(
        $this->getConfigFlag(
            'sandbox_mode'
        ) ? $this->getConfigData('sandbox_webservices_url') : $this->getConfigData('production_webservices_url')
    );

    return $client;
}

I found some thread to add verify_peer => false in the create method of _createSoapClient like below

protected function _createSoapClient($wsdl, $trace = false)
{
    $opts = array(
        'ssl' => array('verify_peer' => false, 'verify_peer_name' => false)
    );
    $client = $this->soapClientFactory->create($wsdl, [
        'trace' => $trace,
        'stream_context' => stream_context_create($opts)          
    ]);
    return $client;
}

This makes it working. But I don’t want to inject code in this file as its a core Magento file. I am looking for some server solution so the verify_peer can be succussed.

Thanks in advance