// GetCriticalExtension returns a requested critical extension. It also remove it from the list // of unhandled critical extensions func GetCriticalExtension(cert *x509.Certificate, oid asn1.ObjectIdentifier) ([]byte, error) { for i, ext := range cert.UnhandledCriticalExtensions { if IntArrayEquals(ext, oid) { cert.UnhandledCriticalExtensions = append(cert.UnhandledCriticalExtensions[:i], cert.UnhandledCriticalExtensions[i+1:]...) break } } for _, ext := range cert.Extensions { if IntArrayEquals(ext.Id, oid) { return ext.Value, nil } } return nil, errors.New("Failed retrieving extension.") }