Esempio n. 1
0
func primaryID(c context.Context) (string, error) {
	rs := &model.AuthReplicationState{}
	if err := model.GetReplicationState(c, rs); err != nil {
		return "", err
	}
	return rs.PrimaryID, nil
}
Esempio n. 2
0
// verifySignature verifies the signature for blob.
func verifySignature(c context.Context, keyName string, blob, sig []byte) error {
	rs := &model.AuthReplicationState{}
	if err := model.GetReplicationState(c, rs); err != nil {
		return err
	}
	certs, err := signature.PrimaryPublicCertificates(c, rs.PrimaryURL)
	if err != nil {
		return err
	}
	pem := signature.X509CertByName(certs, keyName)
	if pem == nil {
		return fmt.Errorf("failed to find cert")
	}
	return signature.Check(blob, pem, sig)
}