Closing connection using TLS

Đang mở
#320 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php
Lĩnh vực
networking

Hướng nghiên cứu

Start in src/Connection.php around the shutdown logic referenced by the issue, then reproduce the provided TLS server example. Compare the proposed fclose and stream_socket_enable_crypto approaches against PHP's TLS shutdown behavior; done means closing the connection cleanly without the current TLS shutdown problem.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

When closing a connection on a server using TLS, eg:

<?php

require __DIR__ . '/vendor/autoload.php';

$server = new React\Socket\TcpServer($port = 9900);
$server = new React\Socket\SecureServer($server, null, [
    'local_cert' => 'server.pem',
    'passphrase' => 'secret'
]);

$server->on('connection', function (React\Socket\ConnectionInterface $connection) {
    echo '[' . $connection->getRemoteAddress() . ' connected]' . PHP_EOL;

    // do stuff
    
    $connection->end();
});

the connection is not closed properly, as https://github.com/reactphp/socket/blob/e04478a14b22c2f85697b917dcc26fa8f1654098/src/Connection.php#L123-L133
uses https://www.php.net/manual/en/function.stream-socket-shutdown.php.

Note comment https://www.php.net/manual/en/function.stream-socket-shutdown.php#125659 which states tls does not get shut down properly that way.

Solution seems to be to replace @\stream_socket_shutdown($this->stream, \STREAM_SHUT_RDWR); with \fclose($this->stream).

Other solution seems to be to call @\stream_socket_enable_crypto($this->stream, false); before the socket shutdown as mentioned in comment https://www.php.net/manual/en/function.stream-socket-shutdown.php#126303

Ngôn ngữ chính
PHP
Star
1.3k
Fork
160
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của reactphp/socket

Tất cả issue của reactphp/socket

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.