Skip to content

Commit 4d824c3

Browse files
authored
Merge pull request #41 from DirectoryTree/fix-stream-transport-key
Use correct `ssl` stream transport options key for `tls`
2 parents 9918c4f + 008daa0 commit 4d824c3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Connection/ImapConnection.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public function connect(string $host, ?int $port = null, array $options = []): v
9292
$this->newParser($this->stream)
9393
);
9494

95-
// If we're using STARTTLS, we first connect plain and then upgrade the connection.
9695
$this->stream->open(
9796
$transport === 'starttls' ? 'tcp' : $transport,
9897
$host,
@@ -123,8 +122,13 @@ protected function getDefaultSocketOptions(string $transport, array $proxy = [],
123122
{
124123
$options = [];
125124

125+
$key = match ($transport) {
126+
'ssl', 'tls' => 'ssl',
127+
'tcp' => 'tcp',
128+
};
129+
126130
if (in_array($transport, ['ssl', 'tls'])) {
127-
$options['ssl'] = [
131+
$options[$key] = [
128132
'verify_peer' => $validateCert,
129133
'verify_peer_name' => $validateCert,
130134
];
@@ -134,13 +138,13 @@ protected function getDefaultSocketOptions(string $transport, array $proxy = [],
134138
return $options;
135139
}
136140

137-
$options[$transport]['proxy'] = $proxy['socket'];
138-
$options[$transport]['request_fulluri'] = $proxy['request_fulluri'] ?? false;
141+
$options[$key]['proxy'] = $proxy['socket'];
142+
$options[$key]['request_fulluri'] = $proxy['request_fulluri'] ?? false;
139143

140144
if (isset($proxy['username'])) {
141145
$auth = base64_encode($proxy['username'].':'.$proxy['password']);
142146

143-
$options[$transport]['header'] = ["Proxy-Authorization: Basic $auth"];
147+
$options[$key]['header'] = ["Proxy-Authorization: Basic $auth"];
144148
}
145149

146150
return $options;

0 commit comments

Comments
 (0)