Skip to content

Commit

Permalink
fix: issuer auto detection logic in wrong method (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: fnerdman <[email protected]>
  • Loading branch information
fnerdman and fnerdman authored Feb 5, 2025
1 parent 2ef3f5b commit a2abde9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions proxy/atls_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ func ParseAttestationType(attestationType string) (AttestationType, error) {
}
}

func CreateAttestationIssuer(log *slog.Logger, attestationType AttestationType) (atls.Issuer, error) {
switch attestationType {
case AttestationNone:
return nil, nil
case AttestationAzureTDX:
return azure_tdx.NewIssuer(log), nil
case AttestationDCAPTDX:
return dcap_tdx.NewIssuer(log), nil
default:
return nil, errors.New("invalid attestation-type passed in")
}
}

// DetectAttestationType determines the attestation type based on environment
func DetectAttestationType() AttestationType {
// Check for TDX device files - these indicate DCAP TDX
Expand All @@ -78,12 +65,25 @@ func DetectAttestationType() AttestationType {
return AttestationNone
}

func CreateAttestationValidators(log *slog.Logger, attestationType AttestationType, jsonMeasurementsPath string) ([]atls.Validator, error) {
func CreateAttestationIssuer(log *slog.Logger, attestationType AttestationType) (atls.Issuer, error) {
if attestationType == AttestationAuto {
attestationType = DetectAttestationType()
log.With("detected_attestation", attestationType).Info("Auto-detected attestation type")
}

switch attestationType {
case AttestationNone:
return nil, nil
case AttestationAzureTDX:
return azure_tdx.NewIssuer(log), nil
case AttestationDCAPTDX:
return dcap_tdx.NewIssuer(log), nil
default:
return nil, errors.New("invalid attestation-type passed in")
}
}

func CreateAttestationValidators(log *slog.Logger, attestationType AttestationType, jsonMeasurementsPath string) ([]atls.Validator, error) {
if attestationType == AttestationNone {
return nil, nil
}
Expand Down

0 comments on commit a2abde9

Please sign in to comment.