government / ratify / error.go

@ 37b1f5914992b1c2410e634b80cb352b72e7f793 | history


package ratify

import "fmt"

// Ratification error codes. Every ratification failure exits with code 2.
const (
	// ErrMalformed: the file is not a readable certificate chain.
	ErrMalformed = "E-MALFORMED"
	// ErrChain: the certificates do not form one valid path from the
	// anchor down.
	ErrChain = "E-CHAIN"
	// ErrTampered: a signature does not match the bytes it covers.
	ErrTampered = "E-TAMPERED"
)

type Error struct {
	Code string
	Msg  string
}

func (e *Error) Error() string { return e.Code + ": " + e.Msg }

func errorf(code, format string, args ...any) *Error {
	return &Error{Code: code, Msg: fmt.Sprintf(format, args...)}
}