ruby-proxifier icon indicating copy to clipboard operation
ruby-proxifier copied to clipboard

Use strict Base64 encoding to prevent bad requests

Open stewartpark opened this issue 4 years ago • 0 comments

With Array#pack, if the credentials is too long, it ends up adding a new line in the middle of the resulting base64 encoded string, which results in a 400 Bad Request. To fix this, Base64.strict_encode64 should be used.

Bad:

CONNECT blah:80 HTTP/1.1
Proxy-Authorization: Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmJiYmJiYmJiYmJiYmJi
YmJiYmJi
...

Good:

CONNECT blah:80 HTTP/1.1
Proxy-Authorization: Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmJiYmJiYmJiYmJiYmJiYmJiYmJi
...

stewartpark avatar Jan 11 '21 22:01 stewartpark