-
-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create profiles integration test (#8003)
This wasn't previously possible because eggsampler/acme didn't support profiles until late last week.
- Loading branch information
1 parent
3e4bc16
commit 63a0e50
Showing
18 changed files
with
127 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
"crypto/ecdsa" | ||
"crypto/elliptic" | ||
"crypto/rand" | ||
"crypto/x509" | ||
"fmt" | ||
"testing" | ||
|
||
|
@@ -31,7 +32,7 @@ func TestCommonNameInCSR(t *testing.T) { | |
san2 := random_domain() | ||
|
||
// Issue a cert. authAndIssue includes the 0th name as the CN by default. | ||
ir, err := authAndIssue(client, key, []string{cn, san1, san2}, true) | ||
ir, err := authAndIssue(client, key, []string{cn, san1, san2}, true, "") | ||
test.AssertNotError(t, err, "failed to issue test cert") | ||
cert := ir.certs[0] | ||
|
||
|
@@ -62,7 +63,7 @@ func TestFirstCSRSANHoistedToCN(t *testing.T) { | |
san2 := "b" + random_domain() | ||
|
||
// Issue a cert using a CSR with no CN set, and the SANs in *non*-alpha order. | ||
ir, err := authAndIssue(client, key, []string{san2, san1}, false) | ||
ir, err := authAndIssue(client, key, []string{san2, san1}, false, "") | ||
test.AssertNotError(t, err, "failed to issue test cert") | ||
cert := ir.certs[0] | ||
|
||
|
@@ -92,7 +93,7 @@ func TestCommonNameSANsTooLong(t *testing.T) { | |
san2 := fmt.Sprintf("thisdomainnameis.morethan64characterslong.forthesakeoftesting.%s", random_domain()) | ||
|
||
// Issue a cert using a CSR with no CN set. | ||
ir, err := authAndIssue(client, key, []string{san1, san2}, false) | ||
ir, err := authAndIssue(client, key, []string{san1, san2}, false, "") | ||
test.AssertNotError(t, err, "failed to issue test cert") | ||
cert := ir.certs[0] | ||
|
||
|
@@ -103,3 +104,49 @@ func TestCommonNameSANsTooLong(t *testing.T) { | |
// Ensure that the CN is empty. | ||
test.AssertEquals(t, cert.Subject.CommonName, "") | ||
} | ||
|
||
// TestIssuanceProfiles verifies that profile selection works, and results in | ||
// measurable differences between certificates issued under different profiles. | ||
// It does not test the omission of the keyEncipherment KU, because all of our | ||
// integration test framework assumes ECDSA pubkeys for the sake of speed, | ||
// and ECDSA certs don't get the keyEncipherment KU in either profile. | ||
func TestIssuanceProfiles(t *testing.T) { | ||
t.Parallel() | ||
|
||
// Create an account. | ||
client, err := makeClient("mailto:[email protected]") | ||
test.AssertNotError(t, err, "creating acme client") | ||
|
||
profiles := client.Directory().Meta.Profiles | ||
if len(profiles) < 2 { | ||
t.Fatal("ACME server not advertising multiple profiles") | ||
} | ||
|
||
// Create a private key. | ||
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) | ||
test.AssertNotError(t, err, "creating random cert key") | ||
|
||
// Create a set of identifiers to request. | ||
names := []string{random_domain()} | ||
|
||
// Get one cert for each profile that we know the test server advertises. | ||
res, err := authAndIssue(client, key, names, true, "legacy") | ||
test.AssertNotError(t, err, "failed to issue under legacy profile") | ||
test.AssertEquals(t, res.Order.Profile, "legacy") | ||
legacy := res.certs[0] | ||
|
||
res, err = authAndIssue(client, key, names, true, "modern") | ||
test.AssertNotError(t, err, "failed to issue under modern profile") | ||
test.AssertEquals(t, res.Order.Profile, "modern") | ||
modern := res.certs[0] | ||
|
||
// Check that each profile worked as expected. | ||
test.AssertEquals(t, legacy.Subject.CommonName, names[0]) | ||
test.AssertEquals(t, modern.Subject.CommonName, "") | ||
|
||
test.AssertDeepEquals(t, legacy.ExtKeyUsage, []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}) | ||
test.AssertDeepEquals(t, modern.ExtKeyUsage, []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}) | ||
|
||
test.AssertEquals(t, len(legacy.SubjectKeyId), 20) | ||
test.AssertEquals(t, len(modern.SubjectKeyId), 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.