func NewVerifier(opts *KeyOptions) (Verifier, error) {
	publicKey := opts.KeyBytes
	if opts.KeyPath != "" {
		raw, err := ioutil.ReadFile(opts.KeyPath)
		if err != nil {
			return nil, err
		}
		publicKey = raw
	}
	block, _ := pem.Decode(publicKey)
	cert, err := x509.ParseCertificate(block.Bytes)
	if err != nil {
		return nil, err
	}
	// TODO
	// Currently only support RSA keys
	// Need to consider DSA/ECDSA
	if cert.PublicKeyAlgorithm != x509.RSA {
		return nil, fmt.Errorf("unsupported public key type")
	}
	return &rsaVerifier{publicKey: cert.PublicKey.(*rsa.PublicKey), cert: cert}, nil
}
func NewVerifier(opts *KeyOptions) (Verifier, error) {
	publicKey := opts.KeyBytes
	if opts.KeyPath != "" {
		raw, err := ioutil.ReadFile(opts.KeyPath)
		if err != nil {
			return nil, err
		}
		publicKey = raw
	}
	block, _ := pem.Decode(publicKey)
	cert, err := x509.ParseCertificate(block.Bytes)
	if err != nil {
		return nil, err
	}
	// TODO
	// Currently only support RSA keys
	// Need to consider DSA/ECDSA
	if cert.PublicKeyAlgorithm != x509.RSA {
		return nil, fmt.Errorf("unsupported public key type")
	}
	return &rsaVerifier{publicKey: cert.PublicKey.(*rsa.PublicKey), cert: cert}, nil
}
func NewVerifier ( opts * KeyOptions ) ( Verifier , error ) { publicKey := opts . KeyBytes if opts . KeyPath != " " { raw , err := ioutil . ReadFile ( opts . KeyPath ) if err != nil { return nil , err } publicKey = raw } block , _ := pem . Decode ( publicKey ) cert , err := x509 . ParseCertificate ( block . Bytes ) if err != nil { return nil , err } // TODO // Currently only support RSA keys // Need to consider DSA/ECDSA if cert . PublicKeyAlgorithm != x509 . RSA { return nil , fmt . Errorf ( " " ) } return & rsaVerifier { publicKey : cert . PublicKey . ( * rsa . PublicKey ) , cert : cert } , nil }
// NewVerifier creates a new RSA backed Verifier
NewVerifier creates a new RSA backed Verifier