'Find attribute. An X509Name object has the following attributes:
countryName (alias C), stateOrProvince (alias ST), locality (alias L),
organization (alias O), organizationalUnit (alias OU), commonName (alias
CN) and more...'

def __getattr__(self, name):

    nid = _lib.OBJ_txt2nid(_byte_string(name))
    if (nid == _lib.NID_undef):
        try:
            _raise_current_error()
        except Error:
            pass
        return super(X509Name, self).__getattr__(name)
    entry_index = _lib.X509_NAME_get_index_by_NID(self._name, nid, (-1))
    if (entry_index == (-1)):
        return None
    entry = _lib.X509_NAME_get_entry(self._name, entry_index)
    data = _lib.X509_NAME_ENTRY_get_data(entry)
    result_buffer = _ffi.new('unsigned    char**')
    data_length = _lib.ASN1_STRING_to_UTF8(result_buffer, data)
    if (data_length < 0):
        _raise_current_error()
    try:
        result = _ffi.buffer(result_buffer[0], data_length)[:].decode('utf-8')
    finally:
        _lib.OPENSSL_free(result_buffer[0])
    return result
