Skip to content

Include measurements in HTTP header to forward them to clients for verifying #15

@ameba23

Description

@ameba23

This is a feature of cvm-reverse-proxy:

func (p *Proxy) copyMeasurementsToHeader(conn *tls.ConnectionState, header *http.Header) (int, error) {
	certs := conn.PeerCertificates
	atlsVariant, extractedMeasurements, err := GetMeasurementsFromTLS(certs, p.validatorOIDs)
	if err != nil {
		return http.StatusTeapot, err
	} else if extractedMeasurements == nil {
		p.log.Debug("[proxy-request: add-headers] no measurements, not adding headers")
		return 0, nil
	}

	measurementsInHeaderFormat := make(map[uint32]string, len(extractedMeasurements))
	for pcr, value := range extractedMeasurements {
		measurementsInHeaderFormat[pcr] = hex.EncodeToString(value)
	}

	marshaledPcrs, err := json.Marshal(measurementsInHeaderFormat)
	if err != nil {
		return http.StatusInternalServerError, errors.New("could not marshal measurement extracted from tls extension")
	}

	header.Set(AttestationTypeHeader, atlsVariant.String())
	header.Set(MeasurementHeader, string(marshaledPcrs))

	p.log.With(AttestationTypeHeader, atlsVariant.String()).With(MeasurementHeader, string(marshaledPcrs)).Debug("[proxy-request: add-headers] measurement headers added")
	return 0, nil
}

This is not so simple to add here as this is a generic TCP proxy service which doesn't (currently) assume HTTP or modify or parse traffic (besides the initial attestation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions