verify.go 876 B

123456789101112131415161718192021222324252627282930313233
  1. package schema1
  2. import (
  3. "crypto/x509"
  4. "github.com/Sirupsen/logrus"
  5. "github.com/docker/libtrust"
  6. )
  7. // Verify verifies the signature of the signed manifest returning the public
  8. // keys used during signing.
  9. func Verify(sm *SignedManifest) ([]libtrust.PublicKey, error) {
  10. js, err := libtrust.ParsePrettySignature(sm.all, "signatures")
  11. if err != nil {
  12. logrus.WithField("err", err).Debugf("(*SignedManifest).Verify")
  13. return nil, err
  14. }
  15. return js.Verify()
  16. }
  17. // VerifyChains verifies the signature of the signed manifest against the
  18. // certificate pool returning the list of verified chains. Signatures without
  19. // an x509 chain are not checked.
  20. func VerifyChains(sm *SignedManifest, ca *x509.CertPool) ([][]*x509.Certificate, error) {
  21. js, err := libtrust.ParsePrettySignature(sm.all, "signatures")
  22. if err != nil {
  23. return nil, err
  24. }
  25. return js.VerifyChains(ca)
  26. }