예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
파일: m2cutils.py 프로젝트: fancyKai/vdsm
    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
예제 #4
0
    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)
예제 #5
0
 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()))
예제 #6
0
 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())