def load_session(pemfile): # type: (AnyStr) -> Session with BIO.openfile(pemfile) as f: cptr = m2.ssl_session_read_pem(f.bio_ptr()) if cptr is None: raise SSLError(Err.get_error()) return Session(cptr, 1)
def load_session(pemfile): f = BIO.openfile(pemfile) cptr = m2.ssl_session_read_pem(f.bio_ptr()) f.close() if cptr is None: from M2Crypto.SSL import SSLError raise SSLError(Err.get_error()) return Session(cptr, 1)
def accept(self): client, address = self.connection.socket.accept() client = SSL.Connection(self.context, client) client.addr = address try: client.setup_ssl() client.set_accept_state() client.settimeout(self.accept_timeout) client.accept_ssl() client.settimeout(None) except SSLError as e: raise SSLError("%s, client %s" % (e, address[0])) client = SSLSocket(client) return client, address
def test_get_releases_throws_exception(self): rb = self._get_rb() # mock content_connection so we can verify it's calls with mock.patch.object(rb, 'content_connection') as mock_cc: mock_cc.get_versions.side_effect = \ httplib.BadStatusLine("some bogus status") releases = rb.get_releases() self.assertEquals([], releases) mock_cc.get_versions.side_effect = \ socket.error() releases = rb.get_releases() self.assertEquals([], releases) mock_cc.get_versions.side_effect = \ SSLError() releases = rb.get_releases() self.assertEquals([], releases)
def set_session_id_ctx(self, id): # type: (bytes) -> int ret = m2.ssl_set_session_id_context(self.ssl, id) if not ret: raise SSLError(m2.err_reason_error_string(m2.err_get_error()))
def set_session_id_ctx(self, id): # type: (bytes) -> int ret = m2.ssl_set_session_id_context(self.ssl, id) if not ret: raise SSLError(Err.get_error_message())