예제 #1
0
 def wrapper(protocol):
     (host, port) = listener
     sslctx = SSLContext(cert_file=CRT_FILE,
                         key_file=KEY_FILE,
                         ca_certs=CRT_FILE,
                         protocol=protocol)
     return utils.create_connected_socket(host, port, sslctx=sslctx)
예제 #2
0
파일: clientIF.py 프로젝트: mpavlase/vdsm
 def _createSSLContext(self):
     sslctx = None
     if config.getboolean('vars', 'ssl'):
         truststore_path = config.get('vars', 'trust_store_path')
         key_file = os.path.join(truststore_path, 'keys', 'vdsmkey.pem')
         cert_file = os.path.join(truststore_path, 'certs', 'vdsmcert.pem')
         ca_cert = os.path.join(truststore_path, 'certs', 'cacert.pem')
         sslctx = SSLContext(cert_file, key_file, ca_cert)
     return sslctx
예제 #3
0
def SimpleClient(host, port=54321, ssl=True):
    """
    Returns JsonRpcClient able to receive jsonrpc messages and notifications.
    It is required to provide a host where we want to connect, port and whether
    we want to use ssl (True by default). Other settings use defaults and if
    there is a need to customize please use StandAloneRpcClient().
    """
    sslctx = None
    if ssl:
        from vdsm.sslutils import SSLContext
        sslctx = SSLContext(key_file=constants.KEY_FILE,
                            cert_file=constants.CERT_FILE,
                            ca_certs=constants.CA_FILE)
    return StandAloneRpcClient(host, port, "jms.topic.vdsm_requests",
                               str(uuid4()), sslctx, lazy_start=False)
예제 #4
0
def listener(dummy_register_protocol_detector, key_cert_pair, request):
    key_file, cert_file = key_cert_pair
    reactor = Reactor()

    sslctx = SSLContext(cert_file=cert_file,
                        key_file=key_file,
                        ca_certs=cert_file)

    acceptor = MultiProtocolAcceptor(reactor, '127.0.0.1', 0, sslctx=sslctx)

    try:
        t = concurrent.thread(reactor.process_requests)
        t.start()
        (host, port) = acceptor._acceptor.socket.getsockname()[0:2]
        yield (host, port)
    finally:
        acceptor.stop()
        t.join()
예제 #5
0
def SimpleClient(host, port=54321, ssl=True, incoming_heartbeat=5000,
                 outgoing_heartbeat=0):
    """
    Returns JsonRpcClient able to receive jsonrpc messages and notifications.
    It is required to provide a host where we want to connect, port and whether
    we want to use ssl (True by default). Other settings use defaults and if
    there is a need to customize please use StandAloneRpcClient().
    """
    sslctx = None
    if ssl:
        from vdsm.sslutils import SSLContext
        sslctx = SSLContext(key_file=pki.KEY_FILE,
                            cert_file=pki.CERT_FILE,
                            ca_certs=pki.CA_FILE,
                            protocol=CLIENT_PROTOCOL)
    return StandAloneRpcClient(host, port, "jms.topic.vdsm_requests",
                               str(uuid4()), sslctx, False,
                               incoming_heartbeat, outgoing_heartbeat)
예제 #6
0
def listener(dummy_register_protocol_detector, request):
    reactor = Reactor()

    excludes = getattr(request, 'param', 0)
    sslctx = SSLContext(cert_file=CRT_FILE,
                        key_file=KEY_FILE,
                        ca_certs=CRT_FILE,
                        excludes=excludes,
                        protocol=CLIENT_PROTOCOL)

    acceptor = MultiProtocolAcceptor(reactor, '127.0.0.1', 0, sslctx=sslctx)

    try:
        t = concurrent.thread(reactor.process_requests)
        t.start()
        (host, port) = acceptor._acceptor.socket.getsockname()[0:2]
        yield (host, port)
    finally:
        acceptor.stop()
        t.join()
예제 #7
0
    def listen(self, excludes=0, protocol=CLIENT_PROTOCOL):
        reactor = Reactor()

        sslctx = SSLContext(cert_file=CRT_FILE,
                            key_file=KEY_FILE,
                            ca_certs=CRT_FILE,
                            excludes=excludes,
                            protocol=protocol)

        acceptor = MultiProtocolAcceptor(reactor,
                                         '127.0.0.1',
                                         0,
                                         sslctx=sslctx)

        try:
            t = concurrent.thread(reactor.process_requests)
            t.start()
            yield self.get_address(acceptor)
        finally:
            acceptor.stop()
            t.join()
예제 #8
0
def SimpleClient(host,
                 port=54321,
                 ssl=True,
                 incoming_heartbeat=DEFAULT_INCOMING,
                 outgoing_heartbeat=DEFAULT_OUTGOING,
                 nr_retries=NR_RETRIES,
                 reconnect_interval=RECONNECT_INTERVAL):
    """
    Returns JsonRpcClient able to receive jsonrpc messages and notifications.
    It is required to provide a host where we want to connect, port and whether
    we want to use ssl (True by default). Other settings use defaults and if
    there is a need to customize please use StandAloneRpcClient().
    """
    sslctx = None
    if ssl:
        sslctx = SSLContext(key_file=pki.KEY_FILE,
                            cert_file=pki.CERT_FILE,
                            ca_certs=pki.CA_FILE)
    return StandAloneRpcClient(host, port, "jms.topic.vdsm_requests",
                               str(uuid4()), sslctx, False, incoming_heartbeat,
                               outgoing_heartbeat, nr_retries,
                               reconnect_interval)
예제 #9
0
파일: stomp.py 프로젝트: chaodongqu/vdsm
 def _create_ssl_context(self):
     return SSLContext(key_file=pki.KEY_FILE,
                       cert_file=pki.CERT_FILE,
                       ca_certs=pki.CA_FILE,
                       protocol=CLIENT_PROTOCOL)
예제 #10
0
 def use_client(self, host, port, protocol):
     sslctx = SSLContext(cert_file=CRT_FILE,
                         key_file=KEY_FILE,
                         ca_certs=CRT_FILE,
                         protocol=protocol)
     utils.create_connected_socket(host, port, sslctx=sslctx)
예제 #11
0
파일: sslhelper.py 프로젝트: wuyeliang/vdsm
#
# Refer to the README and COPYING files for full details of the license
#

from __future__ import absolute_import
from __future__ import division
import os
import ssl
from vdsm.sslutils import CLIENT_PROTOCOL, SSLContext

CERT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
CRT_FILE = os.path.join(CERT_DIR, "server.crt")
KEY_FILE = os.path.join(CERT_DIR, "server.key")
OTHER_CRT_FILE = os.path.join(CERT_DIR, "other.crt")
OTHER_KEY_FILE = os.path.join(CERT_DIR, "other.key")

DEAFAULT_SSL_CONTEXT = SSLContext(cert_file=CRT_FILE,
                                  key_file=KEY_FILE,
                                  ca_certs=CRT_FILE,
                                  protocol=CLIENT_PROTOCOL)


def get_server_socket(key_file, cert_file, socket):
    return ssl.wrap_socket(socket,
                           keyfile=key_file,
                           certfile=cert_file,
                           server_side=False,
                           cert_reqs=ssl.CERT_REQUIRED,
                           ssl_version=CLIENT_PROTOCOL,
                           ca_certs=cert_file)
예제 #12
0
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
#
# Refer to the README and COPYING files for full details of the license
#

import os
from vdsm.sslutils import SSLContext

CERT_DIR = os.path.abspath(os.path.dirname(__file__))
CRT_FILE = os.path.join(CERT_DIR, "server.crt")
KEY_FILE = os.path.join(CERT_DIR, "server.key")
OTHER_CRT_FILE = os.path.join(CERT_DIR, "other.crt")
OTHER_KEY_FILE = os.path.join(CERT_DIR, "other.key")

DEAFAULT_SSL_CONTEXT = SSLContext(CRT_FILE,
                                  KEY_FILE,
                                  session_id="server-tests")
예제 #13
0
파일: sslhelper.py 프로젝트: rexhsu/vdsm
# Refer to the README and COPYING files for full details of the license
#
import os
from six.moves import xmlrpc_server as SimpleXMLRPCServer
import ssl
import threading
from vdsm.sslutils import SSLContext

CERT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
CRT_FILE = os.path.join(CERT_DIR, "server.crt")
KEY_FILE = os.path.join(CERT_DIR, "server.key")
OTHER_CRT_FILE = os.path.join(CERT_DIR, "other.crt")
OTHER_KEY_FILE = os.path.join(CERT_DIR, "other.key")

DEAFAULT_SSL_CONTEXT = SSLContext(cert_file=CRT_FILE,
                                  key_file=KEY_FILE,
                                  ca_certs=CRT_FILE)


def get_server_socket(key_file, cert_file, socket):
    return ssl.wrap_socket(socket,
                           keyfile=key_file,
                           certfile=cert_file,
                           server_side=False,
                           cert_reqs=ssl.CERT_REQUIRED,
                           ssl_version=ssl.PROTOCOL_TLSv1,
                           ca_certs=cert_file)


class TestServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
    def __init__(self, host, service):
예제 #14
0
def create_ssl_context(key_file, cert_file):
    return SSLContext(cert_file=cert_file,
                      key_file=key_file,
                      ca_certs=cert_file)
예제 #15
0
from itertools import product
from vdsm.sslutils import SSLContext
from M2Crypto import SSL
from rpc.BindingXMLRPC import BindingXMLRPC, XmlDetector
from yajsonrpc.stompReactor import StompDetector
from protocoldetector import MultiProtocolAcceptor
from yajsonrpc import JsonRpcClientPool
from rpc.BindingJsonRpc import BindingJsonRpc

CERT_DIR = os.path.abspath(os.path.dirname(__file__))
CRT_FILE = os.path.join(CERT_DIR, "jsonrpc-tests.server.crt")
KEY_FILE = os.path.join(CERT_DIR, "jsonrpc-tests.server.key")
KS_FILE = os.path.join(CERT_DIR, "jsonrpc-tests.p12")

DEAFAULT_SSL_CONTEXT = SSLContext(CRT_FILE,
                                  KEY_FILE,
                                  session_id="json-rpc-tests")

PERMUTATIONS = tuple(product((True, False), ("xml", "stomp")))

TIMEOUT = 3


class FakeClientIf(object):
    log = logging.getLogger("FakeClientIf")

    def __init__(self):
        self.threadLocal = threading.local()
        self.irs = True
        self.gluster = None