Exemple #1
0
func (c *Certificate) GetIssuerName() (*Name, error) {
	n := C.X509_get_issuer_name(c.x)
	if n == nil {
		return nil, errors.New("failed to get issuer name")
	}
	return &Name{name: n}, nil
}
Exemple #2
0
func getCertificate(asn1Data []byte, x509 *C.X509) (*Certificate, error) {
	cert := &Certificate{}
	cert.x509 = x509
	// certificate raw data
	cert.Raw = asn1Data
	// certificate version (zero indexed)
	cert.Version = int(C.X509_get_version_no_macro(cert.x509)) + 1
	// certificate serial number
	cert.SerialNumber = big.NewInt(int64(C.ASN1_INTEGER_get(C.X509_get_serialNumber(cert.x509))))
	// TODO(runcom): store in pkix.Name
	// certificate subject
	cert.Subject = C.GoString(C.X509_NAME_oneline(C.X509_get_subject_name(cert.x509), nil, 0))
	// TODO(runcom): store in pkix.Name
	// certificate issuer
	cert.Issuer = C.GoString(C.X509_NAME_oneline(C.X509_get_issuer_name(cert.x509), nil, 0))
	return cert, nil
}