// ParseCertificates parses one or more certificates from the given ASN.1 DER
// data. The certificates must be concatenated with no intermediate padding.
ParseCertificates parses one or more certificates from the given ASN.1 DER
data. The certificates must be concatenated with no intermediate padding.
// ParseCertificates parses one or more certificates from the given ASN . 1 DER // data . The certificates must be concatenated with no intermediate padding .
func ParseCertificates(asn1Data []byte) ([]*Certificate, error) {
	var (
		cs      []*Certificate
		dlen    = C.long(len(asn1Data))
		p       = C.malloc(C.size_t(len(asn1Data)))
		counter = C.long(0)
		prev    int
	)
	defer C.free(p)
	cBuf := (*[1 << 30]byte)(p)
	copy(cBuf[:], asn1Data)
	for counter < dlen {
		c := C.d2i_X509_with_counter((**C.uchar)(unsafe.Pointer(&cBuf)), dlen, &counter)
		if c == nil {
			return nil, errors.New("error parsing der data: " + sslerr.SSLErrorMessage().String())
		}
		cert, err := getCertificate(asn1Data[prev:counter], c)
		if err != nil {
			return nil, err
		}
		cs = append(cs, cert)
		prev = int(counter)
	}
	return cs, nil
}
func ParseCertificates ( asn1Data [ ] byte ) ( [ ] * Certificate , error ) { var ( cs [ ] * Certificate dlen = C . long ( len ( asn1Data ) ) p = C . malloc ( C . size_t ( len ( asn1Data ) ) ) counter = C . long ( 0 ) prev int ) defer C . free ( p ) cBuf := ( * [ 1 << 30 ] byte ) ( p ) copy ( cBuf [ : ] , asn1Data ) for counter < dlen { c := C . d2i_X509_with_counter ( ( * * C . uchar ) ( unsafe . Pointer ( & cBuf ) ) , dlen , & counter ) if c == nil { return nil , errors . New ( " " + sslerr . SSLErrorMessage ( ) . String ( ) ) } cert , err := getCertificate ( asn1Data [ prev : counter ] , c ) if err != nil { return nil , err } cs = append ( cs , cert ) prev = int ( counter ) } return cs , nil }
ParseCertificates parses one or more certificates from the given ASN.1 DER
data.
ParseCertificates parses one or more certificates from the given ASN . 1 DER data .