@@ -52,10 +52,17 @@ func (rc *WebChecker) CheckStatus(m libkb.MetaContext, h libkb.SigHint, pcm libk
5252//
5353//=============================================================================
5454
55- type WebServiceType struct { libkb.BaseServiceType }
55+ type WebServiceType struct {
56+ libkb.BaseServiceType
57+ scheme string
58+ }
5659
57- func (t WebServiceType ) AllStringKeys () []string { return []string {"web" , "http" , "https" } }
58- func (t WebServiceType ) PrimaryStringKeys () []string { return []string {"https" , "http" } }
60+ func (t WebServiceType ) AllStringKeys () []string {
61+ if t .scheme == "" {
62+ return []string {"web" }
63+ }
64+ return []string {t .scheme }
65+ }
5966
6067func (t WebServiceType ) NormalizeUsername (s string ) (ret string , err error ) {
6168 // The username is just the (lowercased) hostname.
@@ -103,7 +110,14 @@ func (t WebServiceType) NormalizeRemoteName(m libkb.MetaContext, s string) (ret
103110 err = libkb .NewWebUnreachableError (host )
104111 return
105112 }
106- if len (prot ) > 0 && prot == "https" && found != "https:" {
113+ if len (t .scheme ) > 0 && len (prot ) > 0 && prot != t .scheme {
114+ msg := fmt .Sprintf ("You tried to prove ownership of %s over %s but gave a %s link." , host , t .scheme , prot )
115+ err = libkb .NewProtocolSchemeMismatch (msg )
116+ return
117+ }
118+ protocolAssertsHTTPS := prot == "https"
119+ proofTypeAssertsHTTPS := t .scheme == "https"
120+ if (protocolAssertsHTTPS || proofTypeAssertsHTTPS ) && found != "https:" {
107121 msg := fmt .Sprintf ("You specified HTTPS for %s but only HTTP is available" , host )
108122 err = libkb .NewProtocolDowngradeError (msg )
109123 return
@@ -176,3 +190,5 @@ func (t WebServiceType) LastWriterWins() bool { return false }
176190func (t WebServiceType ) MakeProofChecker (l libkb.RemoteProofChainLink ) libkb.ProofChecker {
177191 return & WebChecker {l }
178192}
193+
194+ //=============================================================================
0 commit comments