def __init__(self, protocol, server_side=False): method = _WolfSSLMethod(protocol, server_side) self.protocol = protocol self._side = server_side self._verify_mode = None self.native_object = _lib.wolfSSL_CTX_new(method.native_object) # wolfSSL_CTX_new() takes ownership of the method. # the method is freed later inside wolfSSL_CTX_free() # or if wolfSSL_CTX_new() failed to allocate the context object. method.native_object = _ffi.NULL if self.native_object == _ffi.NULL: raise MemoryError("Unnable to allocate context object") # verify_mode initialization needs a valid native_object. self.verify_mode = CERT_NONE if not server_side: for curve in _SUPPORTED_CURVES: ret = _lib.wolfSSL_CTX_UseSupportedCurve(self.native_object, curve) if ret != _SSL_SUCCESS: raise SSLError("unnable to set curve (%d)" % curve)