port is being stripped off host header
See original GitHub issueExpected Behavior
Restsharp should send Host header as is without modifying port in Host header value. https://github.com/minio/minio-dotnet/pull/212 is bringing in Restsharp 106.2.1 instead of Restsharp.Netcore (non official version with .netcore support). However, we found signature mismatch errors because the custom authenticator in use by minio dotnet sdk creates authorization signature using ip:port as value for the “Host” header. Restsharp httpclient seems to be stripping off the port, as the server trace shows only ip in the host header value.
Actual Behavior
port is being stripped off the “Host” header value in Restsharp 106.2.1
Steps to Reproduce the Problem
- clone minio-dotnet sdk and get patch https://github.com/minio/minio-dotnet/pull/212 ➜ minio-dotnet git:(02cbcb5) ✗ dotnet restore;dotnet build ➜ minio-dotnet git:(02cbcb5) ✗ dotnet run --project SimpleTest
Specifications
- Version:106.2.1
- Platform: Linux/Windows
- Subsystem:
StackTrace
minio-dotnet client side trace
---------------------------------------
Full URL of Request http://192.168.1.157:9000/
Request completed in 90.1376 ms, Request: {
"resource": "/",
"parameters": [
{
"name": "x-amz-content-sha256",
"value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"type": "HttpHeader"
},
{
"name": "Host",
"value": "192.168.1.157:9000",
"type": "HttpHeader"
},
{
"name": "x-amz-date",
"value": "20180221T205958Z",
"type": "HttpHeader"
},
{
"name": "Authorization",
"value": "AWS4-HMAC-SHA256 Credential=minio/20180221/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=db0fbcc9aa66975a530a2621962a87787559289a218da881420686263da862df",
"type": "HttpHeader"
},
{
"name": "Accept",
"value": "application/json, application/xml, text/json, text/x-json, text/javascript, text/xml",
"type": "HttpHeader"
}
],
"method": "GET",
"uri": "http://192.168.1.157:9000/"
}, Response: {
"statusCode": 403,
"content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><Key></Key><BucketName></BucketName><Resource>/</Resource><RequestId>3L137</RequestId><HostId>3L137</HostId></Error>",
"headers": [
{
"Name": "Accept-Ranges",
"Value": "bytes",
"Type": 3,
"ContentType": null
},
{
"Name": "Server",
"Value": "Minio/DEVELOPMENT.GOGET, (linux; amd64)",
"Type": 3,
"ContentType": null
},
{
"Name": "Vary",
"Value": "Origin",
"Type": 3,
"ContentType": null
},
{
"Name": "X-Amz-Request-Id",
"Value": "151572E9DCF94747",
"Type": 3,
"ContentType": null
},
{
"Name": "Date",
"Value": "Wed, 21 Feb 2018 20:59:58 GMT",
"Type": 3,
"ContentType": null
},
{
"Name": "Transfer-Encoding",
"Value": "chunked",
"Type": 3,
"ContentType": null
},
{
"Name": "Content-Type",
"Value": "application/xml",
"Type": 3,
"ContentType": null
}
],
"responseUri": "http://192.168.1.157:9000/",
"errorMessage": null
}
I'm not handling the Minio.Exceptions.MinioException.
Unhandled Exception: System.AggregateException: One or more errors occurred. (Minio API responded with message=The request signature we calculated does not match the signature you provided. Check your key and signing method.) (Minio API responded with message=The request signature we calculated does not match the signature you provided. Check your key and signing method.) ---> Minio.Exceptions.MinioException: Minio API responded with message=The request signature we calculated does not match the signature you provided. Check your key and signing method.
at Minio.MinioClient.ParseError(IRestResponse response) in /home/kris/code/minio-dotnet/Minio/MinioClient.cs:line 475
at Minio.MinioClient.<>c.<.ctor>b__78_0(IRestResponse response) in /home/kris/code/minio-dotnet/Minio/MinioClient.cs:line 70
at Minio.MinioClient.HandleIfErrorResponse(IRestResponse response, IEnumerable`1 handlers, DateTime startTime) in /home/kris/code/minio-dotnet/Minio/MinioClient.cs:line 502
at Minio.MinioClient.<ExecuteTaskAsync>d__81.MoveNext() in /home/kris/code/minio-dotnet/Minio/MinioClient.cs:line 349
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Minio.MinioClient.<ListBucketsAsync>d__0.MoveNext() in /home/kris/code/minio-dotnet/Minio/ApiEndpoints/BucketOperations.cs:line 52
--- End of inner exception stack trace ---
at System.AggregateException.Handle(Func`2 predicate)
at SimpleTest.Program.Main(String[] args) in /home/kris/code/minio-dotnet/SimpleTest/Program.cs:line 47
Server side trace:
--------------------------
➜ minio git:(debugnet) minio server ~/ex
Drive Capacity: 6.9 GiB Free, 221 GiB Total
Endpoint: http://192.168.1.157:9000 http://172.17.0.1:9000 http://172.18.0.1:9000 http://172.19.0.1:9000 http://172.20.0.1:9000 http://127.0.0.1:9000
AccessKey: minio
SecretKey: minio123
Browser Access:
http://192.168.1.157:9000 http://172.17.0.1:9000 http://172.18.0.1:9000 http://172.19.0.1:9000 http://172.20.0.1:9000 http://127.0.0.1:9000
Command-line Access: https://docs.minio.io/docs/minio-client-quickstart-guide
$ mc config host add myminio http://192.168.1.157:9000 minio minio123
Object API (Amazon S3 compatible):
Go: https://docs.minio.io/docs/golang-client-quickstart-guide
Java: https://docs.minio.io/docs/java-client-quickstart-guide
Python: https://docs.minio.io/docs/python-client-quickstart-guide
JavaScript: https://docs.minio.io/docs/javascript-client-quickstart-guide
.NET: https://docs.minio.io/docs/dotnet-client-quickstart-guide
signed headers .... map[X-Amz-Content-Sha256:[e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855] X-Amz-Date:[20180221T205638Z] Host:[192.168.1.157]]
Issue Analytics
- State:
- Created 6 years ago
- Comments:35 (13 by maintainers)
Top Results From Across the Web
Port being stripped off Host header in ...
Following investigations into restsharp/RestSharp#1085, it appears that the Host header HttpRequestMessage constructed by HttpWebRequest.
Read more >Strip port in host header - Help!
Hi. What is the correct way to strip port number in host header? I have an acl: acl srv_all hdr_end(host) -i mydomain.com It...
Read more >Is Port Number Required in HTTP "Host" Header Parameter?
Browsers this day (2013), will actually strip the port from the Host Header when the port is the standard (http port 80, https...
Read more >PK02642: THE PORT NUMBER IN THE HOST HEADER ...
PK02642: THE PORT NUMBER IN THE HOST HEADER WAS STRIPPED BY THE WEB SERVER. A fix is available. Obtain the fix for this...
Read more >Ignore port numbers in haproxy host header matches
HATE! Is there a nicer way of doing this? Can I just tell haproxy to ignore the port in the host header?
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Let’s raise it!
The fix in CoreFx is in the PR: https://github.com/dotnet/corefx/pull/28375