Skip to content

Fix: in the WebSocket Client add-on, fix the base64 encoding#396

Open
Yves57 wants to merge 1 commit into
eclipse-threadx:masterfrom
Yves57:ymarx/fix-websocket-client-base64-encode
Open

Fix: in the WebSocket Client add-on, fix the base64 encoding#396
Yves57 wants to merge 1 commit into
eclipse-threadx:masterfrom
Yves57:ymarx/fix-websocket-client-base64-encode

Conversation

@Yves57

@Yves57 Yves57 commented Jul 5, 2026

Copy link
Copy Markdown

When the number of bytes to encode is not a multiple of 3, the implementation of _nx_utility_base64_encode() uses an extra byte in the input buffer name that must equal to 0 (but this extra-byte must not be counted in name_size).

You can see a comment about that in this source code for example.

The bug causes the WebSocket handshake to fail randomly.

The fix has been double-checked with the following Go code as Base64 encoding reference:

func main() {
	digest := []byte{122, 200, 1, 65, 118, 43, 209, 42, 58, 252, 232, 253, 244, 242, 66, 67, 148, 135, 185, 105}
	key := base64.StdEncoding.EncodeToString(digest)
	fmt.Println(key)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant