Skip to content

Commit

Permalink
attestation: use KDS as fallback if THIM retrieval fails
Browse files Browse the repository at this point in the history
  • Loading branch information
davidweisse committed Apr 25, 2024
1 parent ed4561e commit d79864a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/attestation/snp/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ func (i *Issuer) Issue(_ context.Context, ownPublicKey []byte, nonce []byte) (re
i.logger.Info("Retrieved report", "reportRaw", hex.EncodeToString(reportRaw))

// Get cert chain from THIM
var certChain *spb.CertificateChain
thimRaw, err := i.thimGetter.GetCertification()
if err != nil {
return nil, fmt.Errorf("issuer: getting cert chain from THIM: %w", err)
}
i.logger.Info("Retrieved THIM certification", "thim", thimRaw)
certChain, err := thimRaw.Proto()
if err != nil {
return nil, fmt.Errorf("issuer: converting THIM cert chain: %w", err)
i.logger.Info("Could not retrieve THIM certification", "error", err)
} else {
i.logger.Info("Retrieved THIM certification", "thim", thimRaw)
certChain, err = thimRaw.Proto()
if err != nil {
return nil, fmt.Errorf("issuer: converting THIM cert chain: %w", err)
}
}

// Get SNP product info from cpuid
Expand Down
10 changes: 10 additions & 0 deletions internal/attestation/snp/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ func (v *Validator) Validate(ctx context.Context, attDocRaw []byte, nonce []byte
verifyOpts.CheckRevocations = true
verifyOpts.Getter = v.kdsGetter

var att *sevsnp.Attestation
if attestation.CertificateChain == nil {
v.logger.Info("No THIM certificate found, using KDS instead")
att, err = verify.GetAttestationFromReport(attestation.Report, verifyOpts)
if err != nil {
return fmt.Errorf("converting report to proto: %w", err)
}
attestation.CertificateChain = att.CertificateChain
}

// Report signature verification.

if err := verify.SnpAttestation(attestation, verifyOpts); err != nil {
Expand Down

0 comments on commit d79864a

Please sign in to comment.