Fix host header port mismatch in signing #578
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR includes a bugfix which breaks signing any requests that are sent to a non-default port.
Problem:
There's a mismatch between the host header used for signing vs. the actual request header when connecting to non-default ports.
• During signing: The host header includes port (from URI netloc) and gets added to signed headers. The header does not get added to the final request.
• During request creation: The host header excludes port (from URI host) if not already present.
• Result: The request is signed with
example.com:8080
but sent with the host header having a value ofexample.com
. This creates a signature validation issue server-side.Solution:
This PR updates the CRT client to use netloc, similar to the signer. These values should always match if a given HTTP client is compliant with the HTTP RFCs.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.