Exemplo n.º 1
0
    def __init__(self, protocol, server_side):
        if protocol not in _PROTOCOL_LIST:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_SSLv3:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_TLSv1:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_TLSv1_1:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_TLSv1_2:
            self.native_object =                                     \
                _lib.wolfTLSv1_2_server_method() if server_side else \
                _lib.wolfTLSv1_2_client_method()

        elif protocol in [PROTOCOL_SSLv23, PROTOCOL_TLS]:
            self.native_object =                                    \
                _lib.wolfSSLv23_server_method() if server_side else \
                _lib.wolfSSLv23_client_method()

        if self.native_object == _ffi.NULL:
            raise MemoryError("Unnable to allocate method object")
Exemplo n.º 2
0
    def __init__(self, protocol, server_side):
        if protocol not in _PROTOCOL_LIST:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_SSLv3:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_TLSv1:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_TLSv1_1:
            raise ValueError("this protocol is not supported")

        elif protocol == PROTOCOL_TLSv1_2:
            self.native_object =                                     \
                _lib.wolfTLSv1_2_server_method() if server_side else \
                _lib.wolfTLSv1_2_client_method()

        elif protocol in [PROTOCOL_SSLv23, PROTOCOL_TLS]:
            self.native_object =                                    \
                _lib.wolfSSLv23_server_method() if server_side else \
                _lib.wolfSSLv23_client_method()

        if self.native_object == _ffi.NULL:
            raise MemoryError("Unnable to allocate method object")