Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #1060 #1066

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions PhpAmqpLib/Connection/AMQPConnectionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ final class AMQPConnectionConfig
/** @var string|null */
private $sslKey;

/** @var bool */
private $sslVerify = true;
/** @var bool|null */
private $sslVerify;

/** @var bool|null */
private $sslVerifyName;
Expand Down Expand Up @@ -461,12 +461,12 @@ public function setSslKey(?string $sslKey): void
$this->sslKey = $sslKey;
}

public function getSslVerify(): bool
public function getSslVerify(): ?bool
{
return $this->sslVerify;
}

public function setSslVerify(bool $sslVerify): void
public function setSslVerify(?bool $sslVerify): void
{
$this->sslVerify = $sslVerify;
}
Expand Down
6 changes: 4 additions & 2 deletions PhpAmqpLib/Connection/AMQPSSLConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public function __construct(
?AMQPConnectionConfig $config = null
) {
if (empty($ssl_options)) {
$ssl_options = ['verify_peer' => true];
trigger_error('Using non-TLS instances of AMQPSSLConnection is deprecated and will be removed in version 4 of php-amqplib', E_USER_DEPRECATED);
$ssl_context = null;
} else {
$ssl_context = $this->createSslContext($ssl_options);
}
$ssl_context = $this->createSslContext($ssl_options);
parent::__construct(
$host,
$port,
Expand Down
11 changes: 10 additions & 1 deletion PhpAmqpLib/Wire/IO/StreamIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(
$context = stream_context_create();
}

$this->protocol = $ssl_protocol ?? 'tcp';
$this->protocol = 'tcp';
$this->host = $host;
$this->port = $port;
$this->connection_timeout = $connection_timeout;
Expand All @@ -67,6 +67,15 @@ public function __construct(
$this->canDispatchPcntlSignal = $this->isPcntlSignalEnabled();

stream_context_set_option($this->context, 'socket', 'tcp_nodelay', true);

$options = stream_context_get_options($this->context);
if (!empty($options['ssl'])) {
if (isset($ssl_protocol)) {
$this->protocol = $ssl_protocol;
} else {
$this->protocol = 'ssl';
}
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="E_ALL"/>
<ini name="error_reporting" value="E_ALL ^ E_USER_DEPRECATED"/>
</php>
<logging>
<log type="junit" target="build/report.junit.xml"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/AbstractConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function conection_create(
$config->setSslCaPath($options['ssl']['capath'] ?? null);
$config->setSslCert($options['ssl']['local_cert'] ?? null);
$config->setSslKey($options['ssl']['local_pk'] ?? null);
$config->setSslVerify($options['ssl']['verify_peer'] ?? false);
$config->setSslVerify($options['ssl']['verify_peer'] ?? null);
$config->setSslVerifyName($options['ssl']['verify_peer_name'] ?? null);
$config->setSslPassPhrase($options['ssl']['passphrase'] ?? null);
$config->setSslCiphers($options['ssl']['ciphers'] ?? null);
Expand Down
2 changes: 0 additions & 2 deletions tests/Functional/Connection/AMQPStreamConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class AMQPStreamConnectionTest extends AbstractConnectionTest
*/
public function connection_select_blocking_wo_timeout(): void
{
error_reporting(E_ALL);
ini_set('display_errors', 1);
$connection = $this->conection_create('stream');

$start = microtime(true);
Expand Down
9 changes: 8 additions & 1 deletion tests/Functional/Connection/SSLConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class SSLConnectionTest extends AbstractConnectionTest
*/
public function secure_connection_default_params($options)
{
$connection = $this->conection_create('ssl', HOST, 5671, $options);
$port = $options['port'] ?? 5671;
$connection = $this->conection_create('ssl', HOST, $port, $options);
self::assertTrue($connection->isConnected());
$channel = $connection->channel();
self::assertTrue($channel->is_open());
Expand Down Expand Up @@ -71,6 +72,12 @@ public function secure_connection_params()
$options
];

// #4 non-TLS options
$options = ['port' => 5672];
$sets[] = [
$options
];

return $sets;
}
}