Change all references from SimpleHTTPS -> SimpleHTTP
This commit is contained in:
parent
ef3adda09b
commit
f4ee29d1d3
|
@ -11,10 +11,10 @@ import (
|
|||
blog "github.com/letsencrypt/boulder/log"
|
||||
)
|
||||
|
||||
func SimpleHTTPSChallenge() Challenge {
|
||||
func SimpleHTTPChallenge() Challenge {
|
||||
tls := true
|
||||
return Challenge{
|
||||
Type: ChallengeTypeSimpleHTTPS,
|
||||
Type: ChallengeTypeSimpleHTTP,
|
||||
Status: StatusPending,
|
||||
Token: NewToken(),
|
||||
TLS: &tls,
|
||||
|
|
|
@ -18,12 +18,12 @@ import (
|
|||
// challenges.go
|
||||
|
||||
func TestChallenges(t *testing.T) {
|
||||
simpleHTTPS := SimpleHTTPSChallenge()
|
||||
if simpleHTTPS.Status != StatusPending {
|
||||
t.Errorf("Incorrect status for challenge: %v", simpleHTTPS.Status)
|
||||
simpleHTTP := SimpleHTTPChallenge()
|
||||
if simpleHTTP.Status != StatusPending {
|
||||
t.Errorf("Incorrect status for challenge: %v", simpleHTTP.Status)
|
||||
}
|
||||
if len(simpleHTTPS.Token) != 43 {
|
||||
t.Errorf("Incorrect length for simpleHTTPS token: %v", simpleHTTPS.Token)
|
||||
if len(simpleHTTP.Token) != 43 {
|
||||
t.Errorf("Incorrect length for simpleHTTP token: %v", simpleHTTP.Token)
|
||||
}
|
||||
|
||||
dvsni := DvsniChallenge()
|
||||
|
|
|
@ -38,7 +38,7 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
ChallengeTypeSimpleHTTPS = "simpleHttps"
|
||||
ChallengeTypeSimpleHTTP = "simpleHttp"
|
||||
ChallengeTypeDVSNI = "dvsni"
|
||||
ChallengeTypeDNS = "dns"
|
||||
ChallengeTypeRecoveryToken = "recoveryToken"
|
||||
|
@ -177,10 +177,10 @@ type Challenge struct {
|
|||
// A URI to which a response can be POSTed
|
||||
URI AcmeURL `json:"uri"`
|
||||
|
||||
// Used by simpleHTTPS, recoveryToken, and dns challenges
|
||||
// Used by simpleHTTP, recoveryToken, and dns challenges
|
||||
Token string `json:"token,omitempty"`
|
||||
|
||||
// Used by simpleHTTPS challenges
|
||||
// Used by simpleHTTP challenges
|
||||
Path string `json:"path,omitempty"`
|
||||
TLS *bool `json:"tls,omitempty"`
|
||||
|
||||
|
@ -198,7 +198,7 @@ func (ch Challenge) IsSane(completed bool) bool {
|
|||
}
|
||||
|
||||
switch ch.Type {
|
||||
case ChallengeTypeSimpleHTTPS:
|
||||
case ChallengeTypeSimpleHTTP:
|
||||
// check extra fields aren't used
|
||||
if ch.R != "" || ch.S != "" || ch.Nonce != "" {
|
||||
return false
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestRegistrationUupdate(t *testing.T) {
|
|||
|
||||
func TestSanityCheck(t *testing.T) {
|
||||
tls := true
|
||||
chall := Challenge{Type: ChallengeTypeSimpleHTTPS, Status: StatusValid}
|
||||
chall := Challenge{Type: ChallengeTypeSimpleHTTP, Status: StatusValid}
|
||||
test.Assert(t, !chall.IsSane(false), "IsSane should be false")
|
||||
chall.Status = StatusPending
|
||||
test.Assert(t, !chall.IsSane(false), "IsSane should be false")
|
||||
|
@ -42,7 +42,7 @@ func TestSanityCheck(t *testing.T) {
|
|||
chall.S = "bad"
|
||||
chall.Nonce = "bad"
|
||||
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")
|
||||
chall.Token = ""
|
||||
test.Assert(t, !chall.IsSane(false), "IsSane should be false")
|
||||
|
|
|
@ -140,10 +140,10 @@ func (pa PolicyAuthorityImpl) WillingToIssue(id core.AcmeIdentifier) error {
|
|||
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) {
|
||||
challenges = []core.Challenge{
|
||||
core.SimpleHTTPSChallenge(),
|
||||
core.SimpleHTTPChallenge(),
|
||||
core.DvsniChallenge(),
|
||||
}
|
||||
combinations = [][]int{
|
||||
|
|
|
@ -134,7 +134,7 @@ func TestChallengesFor(t *testing.T) {
|
|||
|
||||
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 {
|
||||
t.Error("Incorrect challenges returned")
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ var (
|
|||
Status: "pending",
|
||||
Challenges: []core.Challenge{
|
||||
core.Challenge{
|
||||
Type: "simpleHttps",
|
||||
Type: "simpleHttp",
|
||||
Status: "pending",
|
||||
URI: core.AcmeURL(*url0),
|
||||
Token: "pDX9vBFJ043_gEc9Wyp8of-SqZMN2H3-fvj5iUgP7mg",
|
||||
|
@ -305,7 +305,7 @@ func TestNewAuthorization(t *testing.T) {
|
|||
|
||||
// TODO Verify that challenges are correct
|
||||
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")
|
||||
|
||||
t.Log("DONE TestNewAuthorization")
|
||||
|
@ -330,8 +330,8 @@ func TestUpdateAuthorization(t *testing.T) {
|
|||
|
||||
// Verify that the responses are reflected
|
||||
test.Assert(t, len(va.Argument.Challenges) > 0, "Authz passed to VA has no challenges")
|
||||
simpleHttps := va.Argument.Challenges[0]
|
||||
test.Assert(t, simpleHttps.Path == Response.Path, "simpleHttps changed")
|
||||
simpleHttp := va.Argument.Challenges[0]
|
||||
test.Assert(t, simpleHttp.Path == Response.Path, "simpleHttp changed")
|
||||
|
||||
t.Log("DONE TestUpdateAuthorization")
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ func TestOnValidationUpdate(t *testing.T) {
|
|||
AuthzUpdated, _ = sa.NewPendingAuthorization(AuthzUpdated)
|
||||
sa.UpdatePendingAuthorization(AuthzUpdated)
|
||||
|
||||
// Simulate a successful simpleHTTPS challenge
|
||||
// Simulate a successful simpleHTTP challenge
|
||||
authzFromVA := AuthzUpdated
|
||||
authzFromVA.Challenges[0].Status = core.StatusValid
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ func TestAddAuthorization(t *testing.T) {
|
|||
uu, err := url.Parse("test.com")
|
||||
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[0] = []int{0, 1}
|
||||
|
|
|
@ -411,13 +411,13 @@ function getReadyToValidate(err, resp, body) {
|
|||
|
||||
var authz = JSON.parse(body);
|
||||
|
||||
var simpleHttps = authz.challenges.filter(function(x) { return x.type == "simpleHttps"; });
|
||||
if (simpleHttps.length == 0) {
|
||||
var simpleHttp = authz.challenges.filter(function(x) { return x.type == "simpleHttp"; });
|
||||
if (simpleHttp.length == 0) {
|
||||
console.log("The server didn't offer any challenges we can handle.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var challenge = simpleHttps[0];
|
||||
var challenge = simpleHttp[0];
|
||||
var path = crypto.randomString(8) + ".txt";
|
||||
var challengePath = ".well-known/acme-challenge/" + path;
|
||||
state.responseURL = challenge["uri"];
|
||||
|
|
|
@ -47,36 +47,36 @@ type verificationRequestEvent struct {
|
|||
|
||||
// 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
|
||||
|
||||
if len(challenge.Path) == 0 {
|
||||
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
|
||||
}
|
||||
|
||||
if identifier.Type != core.IdentifierDNS {
|
||||
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
|
||||
}
|
||||
hostName := identifier.Value
|
||||
var protocol string
|
||||
var scheme string
|
||||
if input.TLS == nil || (input.TLS != nil && *input.TLS) {
|
||||
protocol = "https"
|
||||
scheme = "https"
|
||||
} else {
|
||||
protocol = "http"
|
||||
scheme = "http"
|
||||
}
|
||||
if va.TestMode {
|
||||
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
|
||||
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)
|
||||
if err != nil {
|
||||
challenge.Status = core.StatusInvalid
|
||||
|
@ -109,7 +109,7 @@ func (va ValidationAuthorityImpl) validateSimpleHTTPS(identifier core.AcmeIdenti
|
|||
if subtle.ConstantTimeCompare(body, []byte(challenge.Token)) == 1 {
|
||||
challenge.Status = core.StatusValid
|
||||
} 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
|
||||
}
|
||||
} else if err != nil {
|
||||
|
@ -210,8 +210,8 @@ func (va ValidationAuthorityImpl) validate(authz core.Authorization, challengeIn
|
|||
var err error
|
||||
|
||||
switch authz.Challenges[challengeIndex].Type {
|
||||
case core.ChallengeTypeSimpleHTTPS:
|
||||
authz.Challenges[challengeIndex], err = va.validateSimpleHTTPS(authz.Identifier, authz.Challenges[challengeIndex])
|
||||
case core.ChallengeTypeSimpleHTTP:
|
||||
authz.Challenges[challengeIndex], err = va.validateSimpleHTTP(authz.Identifier, authz.Challenges[challengeIndex])
|
||||
break
|
||||
case core.ChallengeTypeDVSNI:
|
||||
authz.Challenges[challengeIndex], err = va.validateDvsni(authz.Identifier, authz.Challenges[challengeIndex])
|
||||
|
|
|
@ -148,12 +148,12 @@ func dvsniSrv(t *testing.T, R, S []byte, stopChan, waitChan chan bool) {
|
|||
httpsServer.Serve(tlsListener)
|
||||
}
|
||||
|
||||
func TestSimpleHttps(t *testing.T) {
|
||||
func TestSimpleHttp(t *testing.T) {
|
||||
va := NewValidationAuthorityImpl(true)
|
||||
|
||||
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.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 }()
|
||||
<-waitChan
|
||||
|
||||
finChall, err := va.validateSimpleHTTPS(ident, chall)
|
||||
finChall, err := va.validateSimpleHTTP(ident, chall)
|
||||
test.AssertEquals(t, finChall.Status, core.StatusValid)
|
||||
test.AssertNotError(t, err, chall.Path)
|
||||
|
||||
tls := false
|
||||
chall.TLS = &tls
|
||||
finChall, err = va.validateSimpleHTTPS(ident, chall)
|
||||
finChall, err = va.validateSimpleHTTP(ident, chall)
|
||||
test.AssertEquals(t, finChall.Status, core.StatusValid)
|
||||
test.AssertNotError(t, err, chall.Path)
|
||||
|
||||
tls = true
|
||||
chall.TLS = &tls
|
||||
chall.Path = path404
|
||||
invalidChall, err = va.validateSimpleHTTPS(ident, chall)
|
||||
invalidChall, err = va.validateSimpleHTTP(ident, chall)
|
||||
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
|
||||
test.AssertError(t, err, "Should have found a 404 for the challenge.")
|
||||
|
||||
chall.Path = pathWrongToken
|
||||
invalidChall, err = va.validateSimpleHTTPS(ident, chall)
|
||||
invalidChall, err = va.validateSimpleHTTP(ident, chall)
|
||||
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
|
||||
test.AssertError(t, err, "The path should have given us the wrong token.")
|
||||
|
||||
chall.Path = ""
|
||||
invalidChall, err = va.validateSimpleHTTPS(ident, chall)
|
||||
invalidChall, err = va.validateSimpleHTTP(ident, chall)
|
||||
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
|
||||
test.AssertError(t, err, "Empty paths shouldn't work either.")
|
||||
|
||||
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.AssertError(t, err, "IdentifierType IP shouldn't have worked.")
|
||||
|
||||
chall.Path = "wait-long"
|
||||
started := time.Now()
|
||||
invalidChall, err = va.validateSimpleHTTPS(ident, chall)
|
||||
invalidChall, err = va.validateSimpleHTTP(ident, chall)
|
||||
took := time.Since(started)
|
||||
// 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")
|
||||
|
@ -232,7 +232,7 @@ func TestDvsni(t *testing.T) {
|
|||
test.AssertEquals(t, invalidChall.Status, core.StatusInvalid)
|
||||
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.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")
|
||||
}
|
||||
|
||||
func TestValidateHTTPS(t *testing.T) {
|
||||
func TestValidateHTTP(t *testing.T) {
|
||||
va := NewValidationAuthorityImpl(true)
|
||||
mockRA := &MockRegistrationAuthority{}
|
||||
va.RA = mockRA
|
||||
|
||||
challHTTPS := core.SimpleHTTPSChallenge()
|
||||
challHTTPS.Path = "test"
|
||||
challHTTP := core.SimpleHTTPChallenge()
|
||||
challHTTP.Path = "test"
|
||||
|
||||
stopChanHTTPS := make(chan bool, 1)
|
||||
waitChanHTTPS := make(chan bool, 1)
|
||||
go simpleSrv(t, challHTTPS.Token, stopChanHTTPS, waitChanHTTPS)
|
||||
stopChanHTTP := make(chan bool, 1)
|
||||
waitChanHTTP := make(chan bool, 1)
|
||||
go simpleSrv(t, challHTTP.Token, stopChanHTTP, waitChanHTTP)
|
||||
|
||||
// Let them start
|
||||
<-waitChanHTTPS
|
||||
<-waitChanHTTP
|
||||
|
||||
// shutdown cleanly
|
||||
defer func() {
|
||||
stopChanHTTPS <- true
|
||||
stopChanHTTP <- true
|
||||
}()
|
||||
|
||||
var authz = core.Authorization{
|
||||
ID: core.NewToken(),
|
||||
RegistrationID: 1,
|
||||
Identifier: ident,
|
||||
Challenges: []core.Challenge{challHTTPS},
|
||||
Challenges: []core.Challenge{challHTTP},
|
||||
}
|
||||
va.validate(authz, 0)
|
||||
|
||||
|
@ -356,26 +356,26 @@ func TestUpdateValidations(t *testing.T) {
|
|||
mockRA := &MockRegistrationAuthority{}
|
||||
va.RA = mockRA
|
||||
|
||||
challHTTPS := core.SimpleHTTPSChallenge()
|
||||
challHTTPS.Path = "wait"
|
||||
challHTTP := core.SimpleHTTPChallenge()
|
||||
challHTTP.Path = "wait"
|
||||
|
||||
stopChanHTTPS := make(chan bool, 1)
|
||||
waitChanHTTPS := make(chan bool, 1)
|
||||
go simpleSrv(t, challHTTPS.Token, stopChanHTTPS, waitChanHTTPS)
|
||||
stopChanHTTP := make(chan bool, 1)
|
||||
waitChanHTTP := make(chan bool, 1)
|
||||
go simpleSrv(t, challHTTP.Token, stopChanHTTP, waitChanHTTP)
|
||||
|
||||
// Let them start
|
||||
<-waitChanHTTPS
|
||||
<-waitChanHTTP
|
||||
|
||||
// shutdown cleanly
|
||||
defer func() {
|
||||
stopChanHTTPS <- true
|
||||
stopChanHTTP <- true
|
||||
}()
|
||||
|
||||
var authz = core.Authorization{
|
||||
ID: core.NewToken(),
|
||||
RegistrationID: 1,
|
||||
Identifier: ident,
|
||||
Challenges: []core.Challenge{challHTTPS},
|
||||
Challenges: []core.Challenge{challHTTP},
|
||||
}
|
||||
|
||||
started := time.Now()
|
||||
|
|
Loading…
Reference in New Issue