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

fix: should fix #714, closes out issue where length of websocket-sec-key was wrong #900

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/dpp/wsclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ websocket_client::websocket_client(const std::string &hostname, const std::strin
path(urlpath),
data_opcode(opcode)
{
key = std::to_string(time(nullptr));
uint64_t k = (time(nullptr) * time(nullptr));
/* A 64 bit value as hex with leading zeroes is always 16 chars.
*
* The request MUST include a header field with the name
* |Sec-WebSocket-Key|. The value of this header field MUST be a
* nonce consisting of a randomly selected 16-byte value that has
braindigitalis marked this conversation as resolved.
Show resolved Hide resolved
* been base64-encoded (see [Section 4 of
* [RFC4648]](https://datatracker.ietf.org/doc/html/rfc4648#section-4)).
* The nonce MUST be selected randomly for each connection.
*/
key = to_hex<uint64_t>(k);
Mishura4 marked this conversation as resolved.
Show resolved Hide resolved
key = base64_encode(reinterpret_cast<const unsigned char*>(key.c_str()), key.length());
}

Expand Down
Loading