Skip to content

Commit

Permalink
Revert #1060
Browse files Browse the repository at this point in the history
Fixes #1065
  • Loading branch information
lukebakken committed Jan 18, 2023
1 parent 844da68 commit 561d9c0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
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
5 changes: 3 additions & 2 deletions PhpAmqpLib/Connection/AMQPSSLConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ public function __construct(
?AMQPConnectionConfig $config = null
) {
if (empty($ssl_options)) {
$ssl_options = ['verify_peer' => true];
$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 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

0 comments on commit 561d9c0

Please sign in to comment.