src/OpenSSL/crypto.py
def set_reason(self, reason):
        """
        Set the reason of this revocation.

        If :data:`reason` is ``None``, delete the reason instead.

        :param reason: The reason string.
        :type reason: :class:`bytes` or :class:`NoneType`

        :return: ``None``

        .. seealso::

            :meth:`all_reasons`, which gives you a list of all supported
            reasons which you might pass to this method.
        """
        if reason is None:
            self._delete_reason()
        elif not isinstance(reason, bytes):
            raise TypeError("reason must be None or a byte string")
        else:
            reason = reason.lower().replace(b' ', b'')
            reason_code = [r.lower() for r in self._crl_reasons].index(reason)

            new_reason_ext = _lib.ASN1_ENUMERATED_new()
            _openssl_assert(new_reason_ext != _ffi.NULL)
            new_reason_ext = _ffi.gc(new_reason_ext, _lib.ASN1_ENUMERATED_free)

            set_result = _lib.ASN1_ENUMERATED_set(new_reason_ext, reason_code)
            _openssl_assert(set_result != _ffi.NULL)

            self._delete_reason()
            add_result = _lib.X509_REVOKED_add1_ext_i2d(
                self._revoked, _lib.NID_crl_reason, new_reason_ext, 0, 0)
            _openssl_assert(add_result == 1)
def set_reason(self, reason):
        if reason is None:
            self._delete_reason()
        elif not isinstance(reason, bytes):
            raise TypeError("reason must be None or a byte string")
        else:
            reason = reason.lower().replace(b' ', b'')
            reason_code = [r.lower() for r in self._crl_reasons].index(reason)

            new_reason_ext = _lib.ASN1_ENUMERATED_new()
            _openssl_assert(new_reason_ext != _ffi.NULL)
            new_reason_ext = _ffi.gc(new_reason_ext, _lib.ASN1_ENUMERATED_free)

            set_result = _lib.ASN1_ENUMERATED_set(new_reason_ext, reason_code)
            _openssl_assert(set_result != _ffi.NULL)

            self._delete_reason()
            add_result = _lib.X509_REVOKED_add1_ext_i2d(
                self._revoked, _lib.NID_crl_reason, new_reason_ext, 0, 0)
            _openssl_assert(add_result == 1)
def set_reason ( self , reason ) : if reason is None : self . _delete_reason ( ) elif not isinstance ( reason , bytes ) : raise TypeError ( "reason must be None or a byte string" ) else : reason = reason . lower ( ) . replace ( b' ' , b'' ) reason_code = [ r . lower ( ) for r in self . _crl_reasons ] . index ( reason ) new_reason_ext = _lib . ASN1_ENUMERATED_new ( ) _openssl_assert ( new_reason_ext != _ffi . NULL ) new_reason_ext = _ffi . gc ( new_reason_ext , _lib . ASN1_ENUMERATED_free ) set_result = _lib . ASN1_ENUMERATED_set ( new_reason_ext , reason_code ) _openssl_assert ( set_result != _ffi . NULL ) self . _delete_reason ( ) add_result = _lib . X509_REVOKED_add1_ext_i2d ( self . _revoked , _lib . NID_crl_reason , new_reason_ext , 0 , 0 ) _openssl_assert ( add_result == 1 )
Set the reason of this revocation.

        If :data:`reason` is ``None``, delete the reason instead.

        :param reason: The reason string.
        :type reason: :class:`bytes` or :class:`NoneType`

        :return: ``None``

        .. seealso::

            :meth:`all_reasons`, which gives you a list of all supported
            reasons which you might pass to this method.
Set the reason of this revocation .