// ParseCertificate parses a single certificate from the given ASN.1 DER data.
ParseCertificate parses a single certificate from the given ASN.1 DER data.
// ParseCertificate parses a single certificate from the given ASN . 1 DER data .
func ParseCertificate(asn1Data []byte) (*Certificate, error) {
	var (
		c       *C.X509
		dlen    = C.long(len(asn1Data))
		p       = C.malloc(C.size_t(len(asn1Data)))
		counter = C.long(0)
	)
	defer C.free(p)
	cBuf := (*[1 << 30]byte)(p)
	copy(cBuf[:], asn1Data)
	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[:counter], c)
	if err != nil {
		return nil, err
	}
	return cert, nil
}
func ParseCertificate ( asn1Data [ ] byte ) ( * Certificate , error ) { var ( c * C . X509 dlen = C . long ( len ( asn1Data ) ) p = C . malloc ( C . size_t ( len ( asn1Data ) ) ) counter = C . long ( 0 ) ) defer C . free ( p ) cBuf := ( * [ 1 << 30 ] byte ) ( p ) copy ( cBuf [ : ] , asn1Data ) 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 [ : counter ] , c ) if err != nil { return nil , err } return cert , nil }
ParseCertificate parses a single certificate from the given ASN.1 DER data.
ParseCertificate parses a single certificate from the given ASN . 1 DER data .