Skip to content

Commit 9657af6

Browse files
committed
Generate accept header again on repeated use
1 parent 1be49ff commit 9657af6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/Handshake.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public function generateRequest(): string {
6767
}
6868
}
6969

70-
if ($this->accept === null) {
71-
$this->accept = \base64_encode(\random_bytes(self::ACCEPT_NONCE_LENGTH));
72-
}
70+
// This has to be generated for each connect attempt, once a new request has been generated,
71+
// we use the new key for validation.
72+
$this->accept = \base64_encode(\random_bytes(self::ACCEPT_NONCE_LENGTH));
7373

7474
return 'GET ' . $this->path . " HTTP/1.1\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-Websocket-Version: 13\r\nSec-Websocket-Key: {$this->accept}\r\n$headers\r\n";
7575
}

0 commit comments

Comments
 (0)