Commit cc5f752f authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Use secure random to create websocket nonce

parent 39b1a51f
......@@ -543,8 +543,9 @@ int HttpDownstreamConnection::push_request_headers() {
if (req.connect_proto == ConnectProto::WEBSOCKET) {
if (req.http_major == 2) {
std::array<uint8_t, 16> nonce;
util::random_bytes(std::begin(nonce), std::end(nonce),
worker_->get_randgen());
if (RAND_bytes(nonce.data(), nonce.size()) != 1) {
return -1;
}
auto iov = make_byte_ref(balloc, base64::encode_length(nonce.size()) + 1);
auto p = base64::encode(std::begin(nonce), std::end(nonce), iov.base);
*p = '\0';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment