Пример #1
0
def load_dh_params_from_string(ctx, dh_params_string):
    bio = _new_mem_buf()

    _lib.BIO_write(bio, dh_params_string.encode('ascii'), len(dh_params_string.encode('ascii'))) # pylint: disable=no-member
    dh = _lib.PEM_read_bio_DHparams(bio, _ffi.NULL, _ffi.NULL, _ffi.NULL) # pylint: disable=no-member
    dh = _ffi.gc(dh, _lib.DH_free) # pylint: disable=no-member
    _lib.SSL_CTX_set_tmp_dh(ctx._context, dh) # pylint: disable=no-member
Пример #2
0
def load_dh_params_from_string(ctx, dh_params_string):
    bio = _new_mem_buf()

    _lib.BIO_write(bio, str(dh_params_string), len(str(dh_params_string)))
    dh = _lib.PEM_read_bio_DHparams(bio, _ffi.NULL, _ffi.NULL, _ffi.NULL)
    dh = _ffi.gc(dh, _lib.DH_free)
    _lib.SSL_CTX_set_tmp_dh(ctx._context, dh)
Пример #3
0
    def bio_write(self, buf):
        """
        When using non-socket connections this function sends "dirty" data that
        would have traveled in on the network.

        :param buf: The string to put into the memory BIO.
        :return: The number of bytes written
        """
        if self._into_ssl is None:
            raise TypeError("Connection sock was not None")

        if not isinstance(buf, bytes):
            raise TypeError("buf must be a byte string")

        result = _lib.BIO_write(self._into_ssl, buf, len(buf))
        if result <= 0:
            self._handle_bio_errors(self._into_ssl, result)
        return result