// Verify attempts to verify c by building one or more chains from c to a
// certificate in opts.Roots, using certificates in opts.Intermediates if
// needed. If successful, it returns one or more chains where the first
// element of the chain is c and the last element is from opts.Roots.
//
// If opts.Roots is nil and system roots are unavailable the returned error
// will be of type SystemRootsError.
//
// WARNING: this doesn't do any revocation checking.
Verify attempts to verify c by building one or more chains from c to a
certificate in opts.Roots, using certificates in opts.Intermediates if
needed. If successful, it returns one or more chains where the first
element of the chain is c and the last element is from opts.Roots.

If opts.Roots is nil and system roots are unavailable the returned error
will be of type SystemRootsError.

this doesn't do any revocation checking.
// Verify attempts to verify c by building one or more chains from c to a // certificate in opts . Roots using certificates in opts . Intermediates if // needed . If successful it returns one or more chains where the first // element of the chain is c and the last element is from opts . Roots . // // If opts . Roots is nil and system roots are unavailable the returned error // will be of type SystemRootsError . // // WARNING : this doesn ' t do any revocation checking .
func Verify(c *x509.Certificate, opts VerifyOptions) (chains [][]*x509.Certificate, err error) {
	if len(c.Raw) == 0 {
		return nil, errNotParsed
	}
	if opts.Intermediates != nil {
		for _, intermediate := range opts.Intermediates.certs {
			if len(intermediate.Raw) == 0 {
				return nil, errNotParsed
			}
		}
	}
	if opts.Roots == nil && runtime.GOOS == "windows" {
		return systemVerify(c, &opts)
	}
	if len(c.UnhandledCriticalExtensions) > 0 {
		return nil, x509.UnhandledCriticalExtension{}
	}
	if opts.Roots == nil {
		opts.Roots = systemRootsPool()
		if opts.Roots == nil {
			return nil, x509.SystemRootsError{systemRootsErr}
		}
	}
	err = isValid(c, leafCertificate, nil, &opts)
	if err != nil {
		return
	}
	if len(opts.DNSName) > 0 {
		err = c.VerifyHostname(opts.DNSName)
		if err != nil {
			return
		}
	}
	var candidateChains [][]*x509.Certificate
	if opts.Roots.contains(c) {
		candidateChains = append(candidateChains, []*x509.Certificate{c})
	} else {
		if candidateChains, err = buildChains(c, make(map[int][][]*x509.Certificate), []*x509.Certificate{c}, &opts); err != nil {
			return nil, err
		}
	}
	keyUsages := opts.KeyUsages
	if len(keyUsages) == 0 {
		keyUsages = []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}
	}
	for _, usage := range keyUsages {
		if usage == x509.ExtKeyUsageAny {
			chains = candidateChains
			return
		}
	}
	for _, candidate := range candidateChains {
		if checkChainForKeyUsage(candidate, keyUsages) {
			chains = append(chains, candidate)
		}
	}
	if len(chains) == 0 {
		err = CertificateInvalidError{c, IncompatibleUsage}
	}
	return
}
func Verify ( c * x509 . Certificate , opts VerifyOptions ) ( chains [ ] [ ] * x509 . Certificate , err error ) { if len ( c . Raw ) == 0 { return nil , errNotParsed } if opts . Intermediates != nil { for _ , intermediate := range opts . Intermediates . certs { if len ( intermediate . Raw ) == 0 { return nil , errNotParsed } } } if opts . Roots == nil && runtime . GOOS == " " { return systemVerify ( c , & opts ) } if len ( c . UnhandledCriticalExtensions ) > 0 { return nil , x509 . UnhandledCriticalExtension { } } if opts . Roots == nil { opts . Roots = systemRootsPool ( ) if opts . Roots == nil { return nil , x509 . SystemRootsError { systemRootsErr } } } err = isValid ( c , leafCertificate , nil , & opts ) if err != nil { return } if len ( opts . DNSName ) > 0 { err = c . VerifyHostname ( opts . DNSName ) if err != nil { return } } var candidateChains [ ] [ ] * x509 . Certificate if opts . Roots . contains ( c ) { candidateChains = append ( candidateChains , [ ] * x509 . Certificate { c } ) } else { if candidateChains , err = buildChains ( c , make ( map [ int ] [ ] [ ] * x509 . Certificate ) , [ ] * x509 . Certificate { c } , & opts ) ; err != nil { return nil , err } } keyUsages := opts . KeyUsages if len ( keyUsages ) == 0 { keyUsages = [ ] x509 . ExtKeyUsage { x509 . ExtKeyUsageServerAuth } } for _ , usage := range keyUsages { if usage == x509 . ExtKeyUsageAny { chains = candidateChains return } } for _ , candidate := range candidateChains { if checkChainForKeyUsage ( candidate , keyUsages ) { chains = append ( chains , candidate ) } } if len ( chains ) == 0 { err = CertificateInvalidError { c , IncompatibleUsage } } return }
Verify attempts to verify c by building one or more chains from c to a
certificate in opts.Roots, using certificates in opts.Intermediates if
needed.
Verify attempts to verify c by building one or more chains from c to a certificate in opts . Roots using certificates in opts . Intermediates if needed .
// Platform-specific verification needs the ASN.1 contents so // this makes the behavior consistent across platforms. // Use Windows's own verification and chain building. // If any key usage is acceptable then we're done.