taylorfinnell / awscr-signer

AWS request signing in Crystal
MIT License
22 stars 15 forks source link

InvalidSignatureException when keep-alive connection is retried #56

Open carlhoerberg opened 3 years ago

carlhoerberg commented 3 years ago

When a long lived HTTP connection times out and the http client has to reconnect the before_request will be executed again, but then there are already headers which I think this code will use: https://github.com/taylorfinnell/awscr-signer/blob/master/src/awscr-signer/signers/v4.cr#L83-L85

but that results in a InvalidSignatureException. It can be solved by deleting the headers first:

      @http.before_request do |request|
        request.headers.delete "Authorization"
        request.headers.delete "X-Amz-Content-Sha256"
        request.headers.delete "X-Amz-Date"
        signer.sign(request)
      end
jgaskins commented 3 years ago

iiiiinteresting. This sounds similar to the issue I've been having in #52. I'll try your solution in my shard and see if that helps.