mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #7766 from wiserfirst/split_protocol_from_host
Fixed issue incorrect SNI validation when host name contains protocol for SmtpTransport.
This commit is contained in:
commit
5852ecec5a
2 changed files with 23 additions and 1 deletions
|
@ -129,8 +129,12 @@ class CakeSocket {
|
|||
$this->disconnect();
|
||||
}
|
||||
|
||||
$hasProtocol = strpos($this->config['host'], '://') !== false;
|
||||
if ($hasProtocol) {
|
||||
list($this->config['protocol'], $this->config['host']) = explode('://', $this->config['host']);
|
||||
}
|
||||
$scheme = null;
|
||||
if (!empty($this->config['protocol']) && strpos($this->config['host'], '://') === false && empty($this->config['proxy'])) {
|
||||
if (!empty($this->config['protocol'])) {
|
||||
$scheme = $this->config['protocol'] . '://';
|
||||
}
|
||||
|
||||
|
|
|
@ -265,6 +265,24 @@ class CakeSocketTest extends CakeTestCase {
|
|||
$this->Socket->enableCrypto('tls', 'client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that protocol in the host doesn't cause cert errors.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConnectProtocolInHost() {
|
||||
$this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.');
|
||||
$configSslTls = array('host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 5);
|
||||
$socket = new CakeSocket($configSslTls);
|
||||
try {
|
||||
$socket->connect();
|
||||
$this->assertEquals('smtp.gmail.com', $socket->config['host']);
|
||||
$this->assertEquals('ssl', $socket->config['protocol']);
|
||||
} catch (SocketException $e) {
|
||||
$this->markTestSkipped('Cannot test network, skipping.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* _connectSocketToSslTls
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue