Handle Consul API URL protocol mismatch (#10082)

This commit is contained in:
Dave May
2021-02-25 08:22:44 -05:00
committed by GitHub
parent 342a905472
commit d1648243f4
3 changed files with 33 additions and 9 deletions

View File

@@ -1064,6 +1064,10 @@ func (e *external) addr(defaultAddr string) string {
if strings.HasPrefix(e.addrVal, "http:") {
return e.addrVal
}
if strings.HasPrefix(e.addrVal, "https:") {
// Mismatch: e.ssl=false but addrVal is https
return strings.ReplaceAll(e.addrVal, "https://", "http://")
}
return "http://" + e.addrVal
}
@@ -1072,7 +1076,8 @@ func (e *external) addr(defaultAddr string) string {
}
if strings.HasPrefix(e.addrVal, "http:") {
return "https:" + e.addrVal[5:]
// Mismatch: e.ssl=true but addrVal is http
return strings.ReplaceAll(e.addrVal, "http://", "https://")
}
return "https://" + e.addrVal