Change all references from SimpleHTTPS -> SimpleHTTP

This commit is contained in:
Roland Shoemaker 2015-06-12 11:22:04 -07:00
parent ef3adda09b
commit f4ee29d1d3
11 changed files with 64 additions and 64 deletions

View File

@ -11,10 +11,10 @@ import (
blog "github.com/letsencrypt/boulder/log" blog "github.com/letsencrypt/boulder/log"
) )
func SimpleHTTPSChallenge() Challenge { func SimpleHTTPChallenge() Challenge {
tls := true tls := true
return Challenge{ return Challenge{
Type: ChallengeTypeSimpleHTTPS, Type: ChallengeTypeSimpleHTTP,
Status: StatusPending, Status: StatusPending,
Token: NewToken(), Token: NewToken(),
TLS: &tls, TLS: &tls,

View File

@ -18,12 +18,12 @@ import (
// challenges.go // challenges.go
func TestChallenges(t *testing.T) { func TestChallenges(t *testing.T) {
simpleHTTPS := SimpleHTTPSChallenge() simpleHTTP := SimpleHTTPChallenge()
if simpleHTTPS.Status != StatusPending { if simpleHTTP.Status != StatusPending {
t.Errorf("Incorrect status for challenge: %v", simpleHTTPS.Status) t.Errorf("Incorrect status for challenge: %v", simpleHTTP.Status)
} }
if len(simpleHTTPS.Token) != 43 { if len(simpleHTTP.Token) != 43 {
t.Errorf("Incorrect length for simpleHTTPS token: %v", simpleHTTPS.Token) t.Errorf("Incorrect length for simpleHTTP token: %v", simpleHTTP.Token)
} }
dvsni := DvsniChallenge() dvsni := DvsniChallenge()

View File

@ -38,7 +38,7 @@ const (
) )
const ( const (
ChallengeTypeSimpleHTTPS = "simpleHttps" ChallengeTypeSimpleHTTP = "simpleHttp"
ChallengeTypeDVSNI = "dvsni" ChallengeTypeDVSNI = "dvsni"
ChallengeTypeDNS = "dns" ChallengeTypeDNS = "dns"
ChallengeTypeRecoveryToken = "recoveryToken" ChallengeTypeRecoveryToken = "recoveryToken"
@ -177,10 +177,10 @@ type Challenge struct {
// A URI to which a response can be POSTed // A URI to which a response can be POSTed
URI AcmeURL `json:"uri"` URI AcmeURL `json:"uri"`
// Used by simpleHTTPS, recoveryToken, and dns challenges // Used by simpleHTTP, recoveryToken, and dns challenges
Token string `json:"token,omitempty"` Token string `json:"token,omitempty"`
// Used by simpleHTTPS challenges // Used by simpleHTTP challenges
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
TLS *bool `json:"tls,omitempty"` TLS *bool `json:"tls,omitempty"`
@ -198,7 +198,7 @@ func (ch Challenge) IsSane(completed bool) bool {
} }
switch ch.Type { switch ch.Type {
case ChallengeTypeSimpleHTTPS: case ChallengeTypeSimpleHTTP:
// check extra fields aren't used // check extra fields aren't used
if ch.R != "" || ch.S != "" || ch.Nonce != "" { if ch.R != "" || ch.S != "" || ch.Nonce != "" {
return false return false

View File

@ -34,7 +34,7 @@ func TestRegistrationUupdate(t *testing.T) {
func TestSanityCheck(t *testing.T) { func TestSanityCheck(t *testing.T) {
tls := true tls := true
chall := Challenge{Type: ChallengeTypeSimpleHTTPS, Status: StatusValid} chall := Challenge{Type: ChallengeTypeSimpleHTTP, Status: StatusValid}
test.Assert(t, !chall.IsSane(false), "IsSane should be false") test.Assert(t, !chall.IsSane(false), "IsSane should be false")
chall.Status = StatusPending chall.Status = StatusPending
test.Assert(t, !chall.IsSane(false), "IsSane should be false") test.Assert(t, !chall.IsSane(false), "IsSane should be false")
@ -42,7 +42,7 @@ func TestSanityCheck(t *testing.T) {
chall.S = "bad" chall.S = "bad"
chall.Nonce = "bad" chall.Nonce = "bad"
test.Assert(t, !chall.IsSane(false), "IsSane should be false") test.Assert(t, !chall.IsSane(false), "IsSane should be false")
chall = Challenge{Type: ChallengeTypeSimpleHTTPS, Path: "bad", Status: StatusPending} chall = Challenge{Type: ChallengeTypeSimpleHTTP, Path: "bad", Status: StatusPending}
test.Assert(t, !chall.IsSane(false), "IsSane should be false") test.Assert(t, !chall.IsSane(false), "IsSane should be false")
chall.Token = "" chall.Token = ""
test.Assert(t, !chall.IsSane(false), "IsSane should be false") test.Assert(t, !chall.IsSane(false), "IsSane should be false")

View File

@ -140,10 +140,10 @@ func (pa PolicyAuthorityImpl) WillingToIssue(id core.AcmeIdentifier) error {
return nil return nil
} }
// For now, we just issue DVSNI and SimpleHTTPS challenges for everything // For now, we just issue DVSNI and SimpleHTTP challenges for everything
func (pa PolicyAuthorityImpl) ChallengesFor(identifier core.AcmeIdentifier) (challenges []core.Challenge, combinations [][]int) { func (pa PolicyAuthorityImpl) ChallengesFor(identifier core.AcmeIdentifier) (challenges []core.Challenge, combinations [][]int) {
challenges = []core.Challenge{ challenges = []core.Challenge{
core.SimpleHTTPSChallenge(), core.SimpleHTTPChallenge(),
core.DvsniChallenge(), core.DvsniChallenge(),
} }
combinations = [][]int{ combinations = [][]int{

View File

@ -134,7 +134,7 @@ func TestChallengesFor(t *testing.T) {
challenges, combinations := pa.ChallengesFor(core.AcmeIdentifier{}) challenges, combinations := pa.ChallengesFor(core.AcmeIdentifier{})
if len(challenges) != 2 || challenges[0].Type != core.ChallengeTypeSimpleHTTPS || if len(challenges) != 2 || challenges[0].Type != core.ChallengeTypeSimpleHTTP ||
challenges[1].Type != core.ChallengeTypeDVSNI { challenges[1].Type != core.ChallengeTypeDVSNI {
t.Error("Incorrect challenges returned") t.Error("Incorrect challenges returned")
} }

View File

@ -114,7 +114,7 @@ var (
Status: "pending", Status: "pending",
Challenges: []core.Challenge{ Challenges: []core.Challenge{
core.Challenge{ core.Challenge{
Type: "simpleHttps", Type: "simpleHttp",
Status: "pending", Status: "pending",
URI: core.AcmeURL(*url0), URI: core.AcmeURL(*url0),
Token: "pDX9vBFJ043_gEc9Wyp8of-SqZMN2H3-fvj5iUgP7mg", Token: "pDX9vBFJ043_gEc9Wyp8of-SqZMN2H3-fvj5iUgP7mg",
@ -305,7 +305,7 @@ func TestNewAuthorization(t *testing.T) {
// TODO Verify that challenges are correct // TODO Verify that challenges are correct
test.Assert(t, len(authz.Challenges) == 2, "Incorrect number of challenges returned") test.Assert(t, len(authz.Challenges) == 2, "Incorrect number of challenges returned")
test.Assert(t, authz.Challenges[0].Type == core.ChallengeTypeSimpleHTTPS, "Challenge 0 not SimpleHTTPS") test.Assert(t, authz.Challenges[0].Type == core.ChallengeTypeSimpleHTTP, "Challenge 0 not SimpleHTTP")
test.Assert(t, authz.Challenges[1].Type == core.ChallengeTypeDVSNI, "Challenge 1 not DVSNI") test.Assert(t, authz.Challenges[1].Type == core.ChallengeTypeDVSNI, "Challenge 1 not DVSNI")
t.Log("DONE TestNewAuthorization") t.Log("DONE TestNewAuthorization")
@ -330,8 +330,8 @@ func TestUpdateAuthorization(t *testing.T) {
// Verify that the responses are reflected // Verify that the responses are reflected
test.Assert(t, len(va.Argument.Challenges) > 0, "Authz passed to VA has no challenges") test.Assert(t, len(va.Argument.Challenges) > 0, "Authz passed to VA has no challenges")
simpleHttps := va.Argument.Challenges[0] simpleHttp := va.Argument.Challenges[0]
test.Assert(t, simpleHttps.Path == Response.Path, "simpleHttps changed") test.Assert(t, simpleHttp.Path == Response.Path, "simpleHttp changed")
t.Log("DONE TestUpdateAuthorization") t.Log("DONE TestUpdateAuthorization")
} }
@ -341,7 +341,7 @@ func TestOnValidationUpdate(t *testing.T) {
AuthzUpdated, _ = sa.NewPendingAuthorization(AuthzUpdated) AuthzUpdated, _ = sa.NewPendingAuthorization(AuthzUpdated)
sa.UpdatePendingAuthorization(AuthzUpdated) sa.UpdatePendingAuthorization(AuthzUpdated)
// Simulate a successful simpleHTTPS challenge // Simulate a successful simpleHTTP challenge
authzFromVA := AuthzUpdated authzFromVA := AuthzUpdated
authzFromVA.Challenges[0].Status = core.StatusValid authzFromVA.Challenges[0].Status = core.StatusValid

View File

@ -114,7 +114,7 @@ func TestAddAuthorization(t *testing.T) {
uu, err := url.Parse("test.com") uu, err := url.Parse("test.com")
u := core.AcmeURL(*uu) u := core.AcmeURL(*uu)
chall := core.Challenge{Type: "simpleHttps", Status: core.StatusPending, URI: u, Token: "THISWOULDNTBEAGOODTOKEN", Path: "test-me"} chall := core.Challenge{Type: "simpleHttp", Status: core.StatusPending, URI: u, Token: "THISWOULDNTBEAGOODTOKEN", Path: "test-me"}
combos := make([][]int, 1) combos := make([][]int, 1)
combos[0] = []int{0, 1} combos[0] = []int{0, 1}

View File

@ -411,13 +411,13 @@ function getReadyToValidate(err, resp, body) {
var authz = JSON.parse(body); var authz = JSON.parse(body);
var simpleHttps = authz.challenges.filter(function(x) { return x.type == "simpleHttps"; }); var simpleHttp = authz.challenges.filter(function(x) { return x.type == "simpleHttp"; });
if (simpleHttps.length == 0) { if (simpleHttp.length == 0) {
console.log("The server didn't offer any challenges we can handle."); console.log("The server didn't offer any challenges we can handle.");
process.exit(1); process.exit(1);
} }
var challenge = simpleHttps[0]; var challenge = simpleHttp[0];
var path = crypto.randomString(8) + ".txt"; var path = crypto.randomString(8) + ".txt";
var challengePath = ".well-known/acme-challenge/" + path; var challengePath = ".well-known/acme-challenge/" + path;
state.responseURL = challenge["uri"]; state.responseURL = challenge["uri"];

View File

@ -47,36 +47,36 @@ type verificationRequestEvent struct {
// Validation methods // Validation methods
func (va ValidationAuthorityImpl) validateSimpleHTTPS(identifier core.AcmeIdentifier, input core.Challenge) (core.Challenge, error) { func (va ValidationAuthorityImpl) validateSimpleHTTP(identifier core.AcmeIdentifier, input core.Challenge) (core.Challenge, error) {
challenge := input challenge := input
if len(challenge.Path) == 0 { if len(challenge.Path) == 0 {
challenge.Status = core.StatusInvalid challenge.Status = core.StatusInvalid
err := fmt.Errorf("No path provided for SimpleHTTPS challenge.") err := fmt.Errorf("No path provided for SimpleHTTP challenge.")
return challenge, err return challenge, err
} }
if identifier.Type != core.IdentifierDNS { if identifier.Type != core.IdentifierDNS {
challenge.Status = core.StatusInvalid challenge.Status = core.StatusInvalid
err := fmt.Errorf("Identifier type for SimpleHTTPS was not DNS") err := fmt.Errorf("Identifier type for SimpleHTTP was not DNS")
return challenge, err return challenge, err
} }
hostName := identifier.Value hostName := identifier.Value
var protocol string var scheme string
if input.TLS == nil || (input.TLS != nil && *input.TLS) { if input.TLS == nil || (input.TLS != nil && *input.TLS) {
protocol = "https" scheme = "https"
} else { } else {
protocol = "http" scheme = "http"
} }
if va.TestMode { if va.TestMode {
hostName = "localhost:5001" hostName = "localhost:5001"
protocol = "http" scheme = "http"
} }
url := fmt.Sprintf("%s://%s/.well-known/acme-challenge/%s", protocol, hostName, challenge.Path) url := fmt.Sprintf("%s://%s/.well-known/acme-challenge/%s", scheme, hostName, challenge.Path)
// AUDIT[ Certificate Requests ] 11917fa4-10ef-4e0d-9105-bacbe7836a3c // AUDIT[ Certificate Requests ] 11917fa4-10ef-4e0d-9105-bacbe7836a3c
va.log.Audit(fmt.Sprintf("Attempting to validate Simple%s for %s", strings.ToUpper(protocol), url)) va.log.Audit(fmt.Sprintf("Attempting to validate Simple%s for %s", strings.ToUpper(scheme), url))
httpRequest, err := http.NewRequest("GET", url, nil) httpRequest, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
challenge.Status = core.StatusInvalid challenge.Status = core.StatusInvalid
@ -109,7 +109,7 @@ func (va ValidationAuthorityImpl) validateSimpleHTTPS(identifier core.AcmeIdenti
if subtle.ConstantTimeCompare(body, []byte(challenge.Token)) == 1 { if subtle.ConstantTimeCompare(body, []byte(challenge.Token)) == 1 {
challenge.Status = core.StatusValid challenge.Status = core.StatusValid
} else { } else {
err = fmt.Errorf("Incorrect token validating Simple%s for %s", strings.ToUpper(protocol), url) err = fmt.Errorf("Incorrect token validating Simple%s for %s", strings.ToUpper(scheme), url)
challenge.Status = core.StatusInvalid challenge.Status = core.StatusInvalid
} }
} else if err != nil { } else if err != nil {
@ -210,8 +210,8 @@ func (va ValidationAuthorityImpl) validate(authz core.Authorization, challengeIn
var err error var err error
switch authz.Challenges[challengeIndex].Type { switch authz.Challenges[challengeIndex].Type {
case core.ChallengeTypeSimpleHTTPS: case core.ChallengeTypeSimpleHTTP:
authz.Challenges[challengeIndex], err = va.validateSimpleHTTPS(authz.Identifier, authz.Challenges[challengeIndex]) authz.Challenges[challengeIndex], err = va.validateSimpleHTTP(authz.Identifier, authz.Challenges[challengeIndex])
break break
case core.ChallengeTypeDVSNI: case core.ChallengeTypeDVSNI:
authz.Challenges[challengeIndex], err = va.validateDvsni(authz.Identifier, authz.Challenges[challengeIndex]) authz.Challenges[challengeIndex], err = va.validateDvsni(authz.Identifier, authz.Challenges[challengeIndex])

View File

@ -148,12 +148,12 @@ func dvsniSrv(t *testing.T, R, S []byte, stopChan, waitChan chan bool) {
httpsServer.Serve(tlsListener) httpsServer.Serve(tlsListener)
} }
func TestSimpleHttps(t *testing.T) { func TestSimpleHttp(t *testing.T) {
va := NewValidationAuthorityImpl(true) va := NewValidationAuthorityImpl(true)
chall := core.Challenge{Path: "test", Token: expectedToken} chall := core.Challenge{Path: "test", Token: expectedToken}
invalidChall, err := va.validateSimpleHTTPS(ident, chall) invalidChall, err := va.validateSimpleHTTP(ident, chall)
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid) test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
test.AssertError(t, err, "Server's not up yet; expected refusal. Where did we connect?") test.AssertError(t, err, "Server's not up yet; expected refusal. Where did we connect?")
@ -163,41 +163,41 @@ func TestSimpleHttps(t *testing.T) {
defer func() { stopChan <- true }() defer func() { stopChan <- true }()
<-waitChan <-waitChan
finChall, err := va.validateSimpleHTTPS(ident, chall) finChall, err := va.validateSimpleHTTP(ident, chall)
test.AssertEquals(t, finChall.Status, core.StatusValid) test.AssertEquals(t, finChall.Status, core.StatusValid)
test.AssertNotError(t, err, chall.Path) test.AssertNotError(t, err, chall.Path)
tls := false tls := false
chall.TLS = &tls chall.TLS = &tls
finChall, err = va.validateSimpleHTTPS(ident, chall) finChall, err = va.validateSimpleHTTP(ident, chall)
test.AssertEquals(t, finChall.Status, core.StatusValid) test.AssertEquals(t, finChall.Status, core.StatusValid)
test.AssertNotError(t, err, chall.Path) test.AssertNotError(t, err, chall.Path)
tls = true tls = true
chall.TLS = &tls chall.TLS = &tls
chall.Path = path404 chall.Path = path404
invalidChall, err = va.validateSimpleHTTPS(ident, chall) invalidChall, err = va.validateSimpleHTTP(ident, chall)
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid) test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
test.AssertError(t, err, "Should have found a 404 for the challenge.") test.AssertError(t, err, "Should have found a 404 for the challenge.")
chall.Path = pathWrongToken chall.Path = pathWrongToken
invalidChall, err = va.validateSimpleHTTPS(ident, chall) invalidChall, err = va.validateSimpleHTTP(ident, chall)
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid) test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
test.AssertError(t, err, "The path should have given us the wrong token.") test.AssertError(t, err, "The path should have given us the wrong token.")
chall.Path = "" chall.Path = ""
invalidChall, err = va.validateSimpleHTTPS(ident, chall) invalidChall, err = va.validateSimpleHTTP(ident, chall)
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid) test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
test.AssertError(t, err, "Empty paths shouldn't work either.") test.AssertError(t, err, "Empty paths shouldn't work either.")
chall.Path = "validish" chall.Path = "validish"
invalidChall, err = va.validateSimpleHTTPS(core.AcmeIdentifier{Type: core.IdentifierType("ip"), Value: "127.0.0.1"}, chall) invalidChall, err = va.validateSimpleHTTP(core.AcmeIdentifier{Type: core.IdentifierType("ip"), Value: "127.0.0.1"}, chall)
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid) test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
test.AssertError(t, err, "IdentifierType IP shouldn't have worked.") test.AssertError(t, err, "IdentifierType IP shouldn't have worked.")
chall.Path = "wait-long" chall.Path = "wait-long"
started := time.Now() started := time.Now()
invalidChall, err = va.validateSimpleHTTPS(ident, chall) invalidChall, err = va.validateSimpleHTTP(ident, chall)
took := time.Since(started) took := time.Since(started)
// Check that the HTTP connection times out after 5 seconds and doesn't block for 10 seconds // Check that the HTTP connection times out after 5 seconds and doesn't block for 10 seconds
test.Assert(t, (took > (time.Second * 5)), "HTTP timed out before 5 seconds") test.Assert(t, (took > (time.Second * 5)), "HTTP timed out before 5 seconds")
@ -232,7 +232,7 @@ func TestDvsni(t *testing.T) {
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid) test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
test.AssertError(t, err, "R Should be illegal Base64") test.AssertError(t, err, "R Should be illegal Base64")
invalidChall, err = va.validateSimpleHTTPS(core.AcmeIdentifier{Type: core.IdentifierType("ip"), Value: "127.0.0.1"}, chall) invalidChall, err = va.validateSimpleHTTP(core.AcmeIdentifier{Type: core.IdentifierType("ip"), Value: "127.0.0.1"}, chall)
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid) test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
test.AssertError(t, err, "Forgot path; that should be an error.") test.AssertError(t, err, "Forgot path; that should be an error.")
@ -254,31 +254,31 @@ func TestDvsni(t *testing.T) {
test.AssertError(t, err, "Connection should've timed out") test.AssertError(t, err, "Connection should've timed out")
} }
func TestValidateHTTPS(t *testing.T) { func TestValidateHTTP(t *testing.T) {
va := NewValidationAuthorityImpl(true) va := NewValidationAuthorityImpl(true)
mockRA := &MockRegistrationAuthority{} mockRA := &MockRegistrationAuthority{}
va.RA = mockRA va.RA = mockRA
challHTTPS := core.SimpleHTTPSChallenge() challHTTP := core.SimpleHTTPChallenge()
challHTTPS.Path = "test" challHTTP.Path = "test"
stopChanHTTPS := make(chan bool, 1) stopChanHTTP := make(chan bool, 1)
waitChanHTTPS := make(chan bool, 1) waitChanHTTP := make(chan bool, 1)
go simpleSrv(t, challHTTPS.Token, stopChanHTTPS, waitChanHTTPS) go simpleSrv(t, challHTTP.Token, stopChanHTTP, waitChanHTTP)
// Let them start // Let them start
<-waitChanHTTPS <-waitChanHTTP
// shutdown cleanly // shutdown cleanly
defer func() { defer func() {
stopChanHTTPS <- true stopChanHTTP <- true
}() }()
var authz = core.Authorization{ var authz = core.Authorization{
ID: core.NewToken(), ID: core.NewToken(),
RegistrationID: 1, RegistrationID: 1,
Identifier: ident, Identifier: ident,
Challenges: []core.Challenge{challHTTPS}, Challenges: []core.Challenge{challHTTP},
} }
va.validate(authz, 0) va.validate(authz, 0)
@ -356,26 +356,26 @@ func TestUpdateValidations(t *testing.T) {
mockRA := &MockRegistrationAuthority{} mockRA := &MockRegistrationAuthority{}
va.RA = mockRA va.RA = mockRA
challHTTPS := core.SimpleHTTPSChallenge() challHTTP := core.SimpleHTTPChallenge()
challHTTPS.Path = "wait" challHTTP.Path = "wait"
stopChanHTTPS := make(chan bool, 1) stopChanHTTP := make(chan bool, 1)
waitChanHTTPS := make(chan bool, 1) waitChanHTTP := make(chan bool, 1)
go simpleSrv(t, challHTTPS.Token, stopChanHTTPS, waitChanHTTPS) go simpleSrv(t, challHTTP.Token, stopChanHTTP, waitChanHTTP)
// Let them start // Let them start
<-waitChanHTTPS <-waitChanHTTP
// shutdown cleanly // shutdown cleanly
defer func() { defer func() {
stopChanHTTPS <- true stopChanHTTP <- true
}() }()
var authz = core.Authorization{ var authz = core.Authorization{
ID: core.NewToken(), ID: core.NewToken(),
RegistrationID: 1, RegistrationID: 1,
Identifier: ident, Identifier: ident,
Challenges: []core.Challenge{challHTTPS}, Challenges: []core.Challenge{challHTTP},
} }
started := time.Now() started := time.Now()