Use constant value for unix socket so valid host is set in request URL #250
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.
Description
When unix socket is used, usually it's in form like VAULT_ADDR="unix:///var/run/vault.sock"
Currently library correctly detects usage of unix socket based on
unix://
prefix. However later/var/run/vault.sock
is used as Host parameter in HTTP requests over unix socket. It's incorrect as golang URL library expects valid URL in such case so it will try to escape slashes and construct URL in form like:http://%2Fvar%2Frun%2Fvault%2Fvault.sock/v1/secret/data/...
what will cause error as host is incorrect.I propose to use instead "fake" host which is still valid URL as
http://unix.socket/v1/secret/data
is correct from HTTP perspective - later dial function with unix socket will be used anyway (vault-client-go/client.go
Lines 97 to 104 in b335dfa
How has this been tested?
Ran
go test ./...
and tested code locally.