Herman Slatman 4 месяцев назад
Родитель
Сommit
82bf34423c
5 измененных файлов с 24 добавлено и 24 удалено
  1. 2 2
      acme/challenge.go
  2. 1 1
      acme/challenge_test.go
  3. 11 11
      authority/provisioner/acme.go
  4. 8 8
      authority/provisioner/acme_test.go
  5. 2 2
      authority/provisioners.go

+ 2 - 2
acme/challenge.go

@@ -1527,8 +1527,8 @@ func doAndroidKeyAttestationFormat(ctx context.Context, prov Provisioner, ch *Ch
 	intermediates := x509.NewCertPool()
 	intermediates := x509.NewCertPool()
 	var leaf, root *x509.Certificate
 	var leaf, root *x509.Certificate
 	for i, v := range x5c {
 	for i, v := range x5c {
-		der, ok := v.([]byte)
-		if !ok {
+		der, dok := v.([]byte)
+		if !dok {
 			return nil, NewDetailedError(ErrorBadAttestationStatementType, "x5c element is malformed")
 			return nil, NewDetailedError(ErrorBadAttestationStatementType, "x5c element is malformed")
 		}
 		}
 		cert, err := x509.ParseCertificate(der)
 		cert, err := x509.ParseCertificate(der)

+ 1 - 1
acme/challenge_test.go

@@ -114,7 +114,7 @@ func mustAndroidAttestationProvisioner(t *testing.T, roots []byte, androidKeyCRL
 		Type:               "ACME",
 		Type:               "ACME",
 		Name:               "acme",
 		Name:               "acme",
 		Challenges:         []provisioner.ACMEChallenge{provisioner.DEVICE_ATTEST_01},
 		Challenges:         []provisioner.ACMEChallenge{provisioner.DEVICE_ATTEST_01},
-		AttestationFormats: []provisioner.ACMEAttestationFormat{provisioner.ANDROID_KEY},
+		AttestationFormats: []provisioner.ACMEAttestationFormat{provisioner.ANDROIDKEY},
 		AttestationRoots:   roots,
 		AttestationRoots:   roots,
 	}
 	}
 	if err := prov.Init(provisioner.Config{
 	if err := prov.Init(provisioner.Config{

+ 11 - 11
authority/provisioner/acme.go

@@ -60,8 +60,8 @@ func (c ACMEChallenge) Validate() error {
 type ACMEAttestationFormat string
 type ACMEAttestationFormat string
 
 
 const (
 const (
-	// ANDROID_KEY is the format used to enable device-attest-01 on Android devices.
-	ANDROID_KEY ACMEAttestationFormat = "android-key"
+	// ANDROIDKEY is the format used to enable device-attest-01 on Android devices.
+	ANDROIDKEY ACMEAttestationFormat = "android-key"
 
 
 	// APPLE is the format used to enable device-attest-01 on Apple devices.
 	// APPLE is the format used to enable device-attest-01 on Apple devices.
 	APPLE ACMEAttestationFormat = "apple"
 	APPLE ACMEAttestationFormat = "apple"
@@ -84,7 +84,7 @@ func (f ACMEAttestationFormat) String() string {
 // Validate returns an error if the attestation format is not a valid one.
 // Validate returns an error if the attestation format is not a valid one.
 func (f ACMEAttestationFormat) Validate() error {
 func (f ACMEAttestationFormat) Validate() error {
 	switch ACMEAttestationFormat(f.String()) {
 	switch ACMEAttestationFormat(f.String()) {
-	case APPLE, STEP, TPM, ANDROID_KEY:
+	case APPLE, STEP, TPM, ANDROIDKEY:
 		return nil
 		return nil
 	default:
 	default:
 		return fmt.Errorf("acme attestation format %q is not supported", f)
 		return fmt.Errorf("acme attestation format %q is not supported", f)
@@ -271,8 +271,8 @@ func (c *androidCRLCache) snapshot(ctx context.Context, client HTTPClient) (*and
 			return crl, nil
 			return crl, nil
 		}
 		}
 
 
-		// load the CRL. We choose to let all followers get a context.Cancelled when the
-		// leader's ctx is cancelled. Clients will retry after.
+		// load the CRL. We choose to let all followers get a context.Canceled when the
+		// leader's ctx is canceled. Clients will retry after.
 		return c.load(ctx, client)
 		return c.load(ctx, client)
 	})
 	})
 	if err != nil {
 	if err != nil {
@@ -286,7 +286,7 @@ func (c *androidCRLCache) snapshot(ctx context.Context, client HTTPClient) (*and
 // builds the set of revoked serial numbers, and atomically publishes it as the
 // builds the set of revoked serial numbers, and atomically publishes it as the
 // current snapshot.
 // current snapshot.
 func (c *androidCRLCache) load(ctx context.Context, client HTTPClient) (*androidCRL, error) {
 func (c *androidCRLCache) load(ctx context.Context, client HTTPClient) (*androidCRL, error) {
-	var CRLResponse struct {
+	var crlResponse struct {
 		Entries map[string]struct {
 		Entries map[string]struct {
 			Status string `json:"status"`
 			Status string `json:"status"`
 			Reason string `json:"reason"`
 			Reason string `json:"reason"`
@@ -306,7 +306,7 @@ func (c *androidCRLCache) load(ctx context.Context, client HTTPClient) (*android
 		return nil, fmt.Errorf("unexpected Android CRL response %d", res.StatusCode)
 		return nil, fmt.Errorf("unexpected Android CRL response %d", res.StatusCode)
 	}
 	}
 
 
-	if err := json.NewDecoder(res.Body).Decode(&CRLResponse); err != nil {
+	if err := json.NewDecoder(res.Body).Decode(&crlResponse); err != nil {
 		return nil, fmt.Errorf("error decoding Android CRL JSON: %w", err)
 		return nil, fmt.Errorf("error decoding Android CRL JSON: %w", err)
 	}
 	}
 
 
@@ -314,8 +314,8 @@ func (c *androidCRLCache) load(ctx context.Context, client HTTPClient) (*android
 	// based on the status of the certificate. The status can be "REVOKED" and
 	// based on the status of the certificate. The status can be "REVOKED" and
 	// "SUSPENDED"; both statuses result in a certificate being considered
 	// "SUSPENDED"; both statuses result in a certificate being considered
 	// revoked.
 	// revoked.
-	serials := make(map[string]struct{}, len(CRLResponse.Entries))
-	for k := range CRLResponse.Entries {
+	serials := make(map[string]struct{}, len(crlResponse.Entries))
+	for k := range crlResponse.Entries {
 		serials[k] = struct{}{}
 		serials[k] = struct{}{}
 	}
 	}
 
 
@@ -476,7 +476,7 @@ func (p *ACME) IsChallengeEnabled(_ context.Context, challenge ACMEChallenge) bo
 // AttestationFormat provisioner property should have at least one element.
 // AttestationFormat provisioner property should have at least one element.
 func (p *ACME) IsAttestationFormatEnabled(_ context.Context, format ACMEAttestationFormat) bool {
 func (p *ACME) IsAttestationFormatEnabled(_ context.Context, format ACMEAttestationFormat) bool {
 	enabledFormats := []ACMEAttestationFormat{
 	enabledFormats := []ACMEAttestationFormat{
-		APPLE, STEP, TPM, ANDROID_KEY,
+		APPLE, STEP, TPM, ANDROIDKEY,
 	}
 	}
 	if len(p.AttestationFormats) > 0 {
 	if len(p.AttestationFormats) > 0 {
 		enabledFormats = p.AttestationFormats
 		enabledFormats = p.AttestationFormats
@@ -503,7 +503,7 @@ func (p *ACME) GetAttestationRoots() (*x509.CertPool, bool) {
 func (p *ACME) IsAndroidCertificateRevoked(ctx context.Context, cert *x509.Certificate) (bool, error) {
 func (p *ACME) IsAndroidCertificateRevoked(ctx context.Context, cert *x509.Certificate) (bool, error) {
 	// the check only has to be performed when the "android-key" attestation
 	// the check only has to be performed when the "android-key" attestation
 	// format is enabled
 	// format is enabled
-	if !slices.Contains(p.AttestationFormats, ANDROID_KEY) {
+	if !slices.Contains(p.AttestationFormats, ANDROIDKEY) {
 		return false, nil
 		return false, nil
 	}
 	}
 
 

+ 8 - 8
authority/provisioner/acme_test.go

@@ -58,7 +58,7 @@ func TestACMEAttestationFormat_Validate(t *testing.T) {
 		f       ACMEAttestationFormat
 		f       ACMEAttestationFormat
 		wantErr bool
 		wantErr bool
 	}{
 	}{
-		{"android-key", ANDROID_KEY, false},
+		{"android-key", ANDROIDKEY, false},
 		{"apple", APPLE, false},
 		{"apple", APPLE, false},
 		{"step", STEP, false},
 		{"step", STEP, false},
 		{"tpm", TPM, false},
 		{"tpm", TPM, false},
@@ -209,7 +209,7 @@ MCowBQYDK2VwAyEA5c+4NKZSNQcR1T8qN6SjwgdPZQ0Ge12Ylx/YeGAJ35k=
 					Name:               "foo",
 					Name:               "foo",
 					Type:               "ACME",
 					Type:               "ACME",
 					Challenges:         []ACMEChallenge{DNS_01, DEVICE_ATTEST_01},
 					Challenges:         []ACMEChallenge{DNS_01, DEVICE_ATTEST_01},
-					AttestationFormats: []ACMEAttestationFormat{APPLE, STEP, ANDROID_KEY},
+					AttestationFormats: []ACMEAttestationFormat{APPLE, STEP, ANDROIDKEY},
 					AttestationRoots:   bytes.Join([][]byte{appleCA, yubicoCA}, []byte("\n")),
 					AttestationRoots:   bytes.Join([][]byte{appleCA, yubicoCA}, []byte("\n")),
 				},
 				},
 			}
 			}
@@ -437,7 +437,7 @@ func TestACME_IsAttestationFormatEnabled(t *testing.T) {
 		args   args
 		args   args
 		want   bool
 		want   bool
 	}{
 	}{
-		{"ok", fields{[]ACMEAttestationFormat{APPLE, STEP, TPM, ANDROID_KEY}}, args{ctx, TPM}, true},
+		{"ok", fields{[]ACMEAttestationFormat{APPLE, STEP, TPM, ANDROIDKEY}}, args{ctx, TPM}, true},
 		{"ok empty apple", fields{nil}, args{ctx, APPLE}, true},
 		{"ok empty apple", fields{nil}, args{ctx, APPLE}, true},
 		{"ok empty step", fields{nil}, args{ctx, STEP}, true},
 		{"ok empty step", fields{nil}, args{ctx, STEP}, true},
 		{"ok empty tpm", fields{[]ACMEAttestationFormat{}}, args{ctx, "tpm"}, true},
 		{"ok empty tpm", fields{[]ACMEAttestationFormat{}}, args{ctx, "tpm"}, true},
@@ -446,7 +446,7 @@ func TestACME_IsAttestationFormatEnabled(t *testing.T) {
 		{"fail apple", fields{[]ACMEAttestationFormat{STEP, TPM}}, args{ctx, APPLE}, false},
 		{"fail apple", fields{[]ACMEAttestationFormat{STEP, TPM}}, args{ctx, APPLE}, false},
 		{"fail step", fields{[]ACMEAttestationFormat{APPLE, TPM}}, args{ctx, STEP}, false},
 		{"fail step", fields{[]ACMEAttestationFormat{APPLE, TPM}}, args{ctx, STEP}, false},
 		{"fail step", fields{[]ACMEAttestationFormat{APPLE, STEP}}, args{ctx, TPM}, false},
 		{"fail step", fields{[]ACMEAttestationFormat{APPLE, STEP}}, args{ctx, TPM}, false},
-		{"fail android", fields{[]ACMEAttestationFormat{APPLE, STEP}}, args{ctx, ANDROID_KEY}, false},
+		{"fail android", fields{[]ACMEAttestationFormat{APPLE, STEP}}, args{ctx, ANDROIDKEY}, false},
 	}
 	}
 	for _, tt := range tests {
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 		t.Run(tt.name, func(t *testing.T) {
@@ -499,7 +499,7 @@ func TestACME_IsAndroidCertificateRevoked(t *testing.T) {
 	p := &ACME{
 	p := &ACME{
 		Type:               "ACME",
 		Type:               "ACME",
 		Name:               "acme",
 		Name:               "acme",
-		AttestationFormats: []ACMEAttestationFormat{ANDROID_KEY},
+		AttestationFormats: []ACMEAttestationFormat{ANDROIDKEY},
 	}
 	}
 	require.NoError(t, p.Init(Config{
 	require.NoError(t, p.Init(Config{
 		Claims:     globalProvisionerClaims,
 		Claims:     globalProvisionerClaims,
@@ -539,7 +539,7 @@ func TestACME_IsAndroidCertificateRevoked_controller(t *testing.T) {
 	p := &ACME{
 	p := &ACME{
 		Type:               "ACME",
 		Type:               "ACME",
 		Name:               "acme",
 		Name:               "acme",
-		AttestationFormats: []ACMEAttestationFormat{ANDROID_KEY},
+		AttestationFormats: []ACMEAttestationFormat{ANDROIDKEY},
 	}
 	}
 	require.NoError(t, p.Init(Config{
 	require.NoError(t, p.Init(Config{
 		Claims:               globalProvisionerClaims,
 		Claims:               globalProvisionerClaims,
@@ -566,7 +566,7 @@ func TestACME_IsAndroidCertificateRevoked_controllerError(t *testing.T) {
 	p := &ACME{
 	p := &ACME{
 		Type:               "ACME",
 		Type:               "ACME",
 		Name:               "acme",
 		Name:               "acme",
-		AttestationFormats: []ACMEAttestationFormat{ANDROID_KEY},
+		AttestationFormats: []ACMEAttestationFormat{ANDROIDKEY},
 	}
 	}
 	require.NoError(t, p.Init(Config{
 	require.NoError(t, p.Init(Config{
 		Claims:               globalProvisionerClaims,
 		Claims:               globalProvisionerClaims,
@@ -611,7 +611,7 @@ func TestACME_IsAndroidCertificateRevoked_failsClosed(t *testing.T) {
 	p := &ACME{
 	p := &ACME{
 		Type:               "ACME",
 		Type:               "ACME",
 		Name:               "acme",
 		Name:               "acme",
-		AttestationFormats: []ACMEAttestationFormat{ANDROID_KEY},
+		AttestationFormats: []ACMEAttestationFormat{ANDROIDKEY},
 	}
 	}
 	require.NoError(t, p.Init(Config{
 	require.NoError(t, p.Init(Config{
 		Claims:     globalProvisionerClaims,
 		Claims:     globalProvisionerClaims,

+ 2 - 2
authority/provisioners.go

@@ -1361,7 +1361,7 @@ func attestationFormatsToCertificates(formats []linkedca.ACMEProvisioner_Attesta
 	for _, f := range formats {
 	for _, f := range formats {
 		switch f {
 		switch f {
 		case linkedca.ACMEProvisioner_ANDROID_KEY:
 		case linkedca.ACMEProvisioner_ANDROID_KEY:
-			ret = append(ret, provisioner.ANDROID_KEY)
+			ret = append(ret, provisioner.ANDROIDKEY)
 		case linkedca.ACMEProvisioner_APPLE:
 		case linkedca.ACMEProvisioner_APPLE:
 			ret = append(ret, provisioner.APPLE)
 			ret = append(ret, provisioner.APPLE)
 		case linkedca.ACMEProvisioner_STEP:
 		case linkedca.ACMEProvisioner_STEP:
@@ -1379,7 +1379,7 @@ func attestationFormatsToLinkedca(formats []provisioner.ACMEAttestationFormat) [
 	ret := make([]linkedca.ACMEProvisioner_AttestationFormatType, 0, len(formats))
 	ret := make([]linkedca.ACMEProvisioner_AttestationFormatType, 0, len(formats))
 	for _, f := range formats {
 	for _, f := range formats {
 		switch provisioner.ACMEAttestationFormat(f.String()) {
 		switch provisioner.ACMEAttestationFormat(f.String()) {
-		case provisioner.ANDROID_KEY:
+		case provisioner.ANDROIDKEY:
 			ret = append(ret, linkedca.ACMEProvisioner_ANDROID_KEY)
 			ret = append(ret, linkedca.ACMEProvisioner_ANDROID_KEY)
 		case provisioner.APPLE:
 		case provisioner.APPLE:
 			ret = append(ret, linkedca.ACMEProvisioner_APPLE)
 			ret = append(ret, linkedca.ACMEProvisioner_APPLE)