func()

in ccadb2OneCRL/onecrl/onecrl.go [185:222]


func (r *Record) ToComparison() (interface{}, error) {
	cert, err := r.CCADB.ParseCertificate()
	if err != nil {
		return nil, fmt.Errorf("failed to parse the certificate bundled with the CCADB when building a comparison "+
			"between the CCADB and OneCRL, err: %v", err)
	}
	switch r.Type() {
	case set.IssuerSerialType:
		return IssuerSerialComparison{
			Issuer: Comparison{
				OneCRL: r.IssuerName,
				CCADB:  cert.Issuer.String(),
			},
			Serial: Comparison{
				OneCRL: r.SerialNumber,
				CCADB:  r.CCADB.CertificateSerialNumber,
			},
		}, nil
	case set.SubjectKeyHashType:
		raw, err := utils.B64Decode(r.PubKeyHash)
		if err != nil {
			return nil, err
		}
		return SubjectKeyHashComparison{
			Subject: Comparison{
				OneCRL: r.Subject,
				CCADB:  cert.Subject.String(),
			},
			Keyhash: Comparison{
				OneCRL: r.PubKeyHash,
				CCADB:  fmt.Sprintf("%X", raw),
			},
		}, nil
	default:
		log.Panic("non-exhaustive switch")
		return nil, nil
	}
}