Skip to content

Commit c71c3cf

Browse files
calaverajsha
authored andcommitted
Implement TLS-SNI-02 challenge validations. (letsencrypt#2585)
I think these are all the necessary changes to implement TLS-SNI-02 validations, according to the section 7.3 of draft 05: https://tools.ietf.org/html/draft-ietf-acme-acme-05#section-7.3 I don't have much experience with this code, I'll really appreciate your feedback. Signed-off-by: David Calavera <david.calavera@gmail.com>
1 parent 8f1de3b commit c71c3cf

File tree

12 files changed

+267
-52
lines changed

12 files changed

+267
-52
lines changed

core/challenges.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ func HTTPChallenge01() Challenge {
1313
return newChallenge(ChallengeTypeHTTP01)
1414
}
1515

16-
// TLSSNIChallenge01 constructs a random tls-sni-00 challenge
16+
// TLSSNIChallenge01 constructs a random tls-sni-01 challenge
1717
func TLSSNIChallenge01() Challenge {
1818
return newChallenge(ChallengeTypeTLSSNI01)
1919
}
2020

21-
// DNSChallenge01 constructs a random DNS challenge
21+
// TLSSNIChallenge02 constructs a random tls-sni-02 challenge
22+
func TLSSNIChallenge02() Challenge {
23+
return newChallenge(ChallengeTypeTLSSNI02)
24+
}
25+
26+
// DNSChallenge01 constructs a random dns-01 challenge
2227
func DNSChallenge01() Challenge {
2328
return newChallenge(ChallengeTypeDNS01)
2429
}

core/core_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"testing"
77

8+
"github.com/letsencrypt/boulder/features"
89
"github.com/letsencrypt/boulder/test"
910
"gopkg.in/square/go-jose.v1"
1011
)
@@ -34,6 +35,11 @@ func TestChallenges(t *testing.T) {
3435
t.Errorf("New tls-sni-01 challenge is not sane: %v", tlssni01)
3536
}
3637

38+
tlssni02 := TLSSNIChallenge02()
39+
if !tlssni02.IsSane(false) {
40+
t.Errorf("New tls-sni-02 challenge is not sane: %v", tlssni02)
41+
}
42+
3743
dns01 := DNSChallenge01()
3844
if !dns01.IsSane(false) {
3945
t.Errorf("New dns-01 challenge is not sane: %v", dns01)
@@ -43,6 +49,13 @@ func TestChallenges(t *testing.T) {
4349
test.Assert(t, ValidChallenge(ChallengeTypeTLSSNI01), "Refused valid challenge")
4450
test.Assert(t, ValidChallenge(ChallengeTypeDNS01), "Refused valid challenge")
4551
test.Assert(t, !ValidChallenge("nonsense-71"), "Accepted invalid challenge")
52+
53+
test.Assert(t, !ValidChallenge(ChallengeTypeTLSSNI02), "Accepted invalid challenge")
54+
55+
_ = features.Set(map[string]bool{"AllowTLS02Challenges": true})
56+
defer features.Reset()
57+
58+
test.Assert(t, ValidChallenge(ChallengeTypeTLSSNI02), "Refused valid challenge")
4659
}
4760

4861
// objects.go

core/objects.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"gopkg.in/square/go-jose.v1"
1414

15+
"github.com/letsencrypt/boulder/features"
1516
"github.com/letsencrypt/boulder/probs"
1617
"github.com/letsencrypt/boulder/revocation"
1718
)
@@ -69,6 +70,7 @@ const (
6970
const (
7071
ChallengeTypeHTTP01 = "http-01"
7172
ChallengeTypeTLSSNI01 = "tls-sni-01"
73+
ChallengeTypeTLSSNI02 = "tls-sni-02"
7274
ChallengeTypeDNS01 = "dns-01"
7375
)
7476

@@ -81,6 +83,8 @@ func ValidChallenge(name string) bool {
8183
fallthrough
8284
case ChallengeTypeDNS01:
8385
return true
86+
case ChallengeTypeTLSSNI02:
87+
return features.Enabled(features.AllowTLS02Challenges)
8488

8589
default:
8690
return false
@@ -261,6 +265,8 @@ func (ch Challenge) RecordsSane() bool {
261265
}
262266
}
263267
case ChallengeTypeTLSSNI01:
268+
fallthrough
269+
case ChallengeTypeTLSSNI02:
264270
if len(ch.ValidationRecord) > 1 {
265271
return false
266272
}

core/objects_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestChallengeSanityCheck(t *testing.T) {
5757
}`), &accountKey)
5858
test.AssertNotError(t, err, "Error unmarshaling JWK")
5959

60-
types := []string{ChallengeTypeHTTP01, ChallengeTypeTLSSNI01, ChallengeTypeDNS01}
60+
types := []string{ChallengeTypeHTTP01, ChallengeTypeTLSSNI01, ChallengeTypeTLSSNI02, ChallengeTypeDNS01}
6161
for _, challengeType := range types {
6262
chall := Challenge{
6363
Type: challengeType,

features/featureflag_string.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/features.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
ResubmitMissingSCTsOnly
1919
GoogleSafeBrowsingV4
2020
UseAIAIssuerURL
21+
AllowTLS02Challenges
2122
)
2223

2324
// List of features and their default value, protected by fMu
@@ -29,6 +30,7 @@ var features = map[FeatureFlag]bool{
2930
ResubmitMissingSCTsOnly: false,
3031
GoogleSafeBrowsingV4: false,
3132
UseAIAIssuerURL: false,
33+
AllowTLS02Challenges: false,
3234
}
3335

3436
var fMu = new(sync.RWMutex)

policy/pa.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ func (pa *AuthorityImpl) ChallengesFor(identifier core.AcmeIdentifier) ([]core.C
286286
challenges = append(challenges, core.TLSSNIChallenge01())
287287
}
288288

289+
if features.Enabled(features.AllowTLS02Challenges) && pa.enabledChallenges[core.ChallengeTypeTLSSNI02] {
290+
challenges = append(challenges, core.TLSSNIChallenge02())
291+
}
292+
289293
if pa.enabledChallenges[core.ChallengeTypeDNS01] {
290294
challenges = append(challenges, core.DNSChallenge01())
291295
}

test/config-next/ca.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@
134134
"serviceQueue": "CA.server"
135135
},
136136
"features": {
137-
"IDNASupport": true
137+
"IDNASupport": true,
138+
"AllowTLS02Challenges": true
138139
}
139140
},
140141

test/config-next/cert-checker.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"dbConnectFile": "test/secrets/cert_checker_dburl",
44
"maxDBConns": 10,
55
"features": {
6-
"IDNASupport": true
6+
"IDNASupport": true,
7+
"AllowTLS02Challenges": true
78
},
89
"hostnamePolicyFile": "test/hostname-policy.json"
910
},
@@ -12,7 +13,8 @@
1213
"challenges": {
1314
"http-01": true,
1415
"tls-sni-01": true,
15-
"dns-01": true
16+
"dns-01": true,
17+
"tls-sni-02": true
1618
}
1719
},
1820

test/config-next/ra.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
},
4747
"features": {
4848
"IDNASupport": true,
49-
"AllowKeyRollover": true
49+
"AllowKeyRollover": true,
50+
"AllowTLS02Challenges": true
5051
}
5152
},
5253

0 commit comments

Comments
 (0)