示例#1
0
 def init_with_bundle(self, info):
     """
     Init the peer with given info dict
     :param info: Dict including all info, e.g., endpoint, grpc option
     :return: True or False
     """
     try:
         self._endpoint = info['url']
         self._grpc_options = info['grpcOptions']
         self._tls_ca_certs_path = info['tlsCACerts']['path']
         if 'clientKey' in info:
             self._client_key_path = info['clientKey']['path']
         if 'clientCert' in info:
             self._client_cert_path = info['clientCert']['path']
         self._ssl_target_name = self._grpc_options[
             'grpc.ssl_target_name_override']
         self._channel = create_grpc_channel(
             self._endpoint,
             self._tls_ca_certs_path,
             self._client_key_path,
             self._client_cert_path,
             opts=[(opt, value)
                   for opt, value in self._grpc_options.items()])
         self._orderer_client = ab_pb2_grpc.AtomicBroadcastStub(
             self._channel)
     except KeyError as e:
         print(e)
         return False
     return True
示例#2
0
    def __init__(self,
                 name='orderer',
                 endpoint=DEFAULT_ORDERER_ENDPOINT,
                 tls_ca_cert_file=None,
                 client_key_file=None,
                 client_cert_file=None,
                 opts=None):
        """Creates an orderer object.

        Args:
            endpoint (str): The grpc endpoint of the orderer.
            tls_ca_cert_file (str): The tls certificate for the given
                orderer as bytes.
            client_key (str): file path for Private key used for TLS when
                making client connections
            client_cert (str): file path for X.509 certificate used for TLS
                when making client connections
            opts (tuple): Additional grpc config options as
                tuple e.g. ((key, val),).

        """
        self._name = name
        self._endpoint = endpoint
        self._grpc_options = dict()
        self._ssl_target_name = None
        self._tls_ca_certs_path = tls_ca_cert_file
        self._client_key_path = client_key_file
        self._client_cert_path = client_cert_file
        self._channel = create_grpc_channel(self._endpoint, tls_ca_cert_file,
                                            client_key_file, client_cert_file,
                                            opts)
        self._orderer_client = ab_pb2_grpc.AtomicBroadcastStub(self._channel)
示例#3
0
    def set_tls_client_cert_and_key(self,
                                    client_key_file=None,
                                    client_cert_file=None):
        """Set tls client's cert and key for mutual tls

        :param client_key_file: file path for Private key used for TLS when making client connections,
                                defaults to None
        :type client_key_file: str
        :param client_cert_file: file path for X.509 certificate used for TLS when making client connections,
                                 defaults to None
        :type client_cert_file: str
        :return: set success value
        :rtype: Boolean
        """

        try:
            self._client_key_path = client_key_file
            self._client_cert_path = client_cert_file
            self._channel = create_grpc_channel(
                self._endpoint,
                self._tls_ca_certs_path,
                self._client_key_path,
                self._client_cert_path,
                opts=[(opt, value)
                      for opt, value in self._grpc_options.items()])
            self._orderer_client = ab_pb2_grpc.AtomicBroadcastStub(
                self._channel)
        except Exception:
            return False
        return True
示例#4
0
    def __init__(self, name='orderer', endpoint=DEFAULT_ORDERER_ENDPOINT,
                 tls_ca_cert_file=None, client_key_file=None,
                 client_cert_file=None, opts=None):
        """Creates an orderer object.

        :param name: defaults to 'orderer'
        :type name: str
        :param endpoint: The grpc endpoint of the orderer, defaults to DEFAULT_ORDERER_ENDPOINT
        :type endpoint: str
        :param tls_ca_cert_file: The tls certificate for the given orderer as bytes, defaults to None
        :type tls_ca_cert_file: str
        :param client_key_file: file path for Private key used for TLS when making client connections,
                                defaults to None
        :type client_key_file: str
        :param client_cert_file: file path for X.509 certificate used for TLS when making client connections,
                                 defaults to None
        :type client_cert_file: str
        :param opts: Additional grpc config options as tuple e.g. ((key, val),), defaults to None
        :type opts: tuple
        """

        self._name = name
        self._endpoint = endpoint
        if opts:
            self._grpc_options = {key: value for (key, value) in opts}
        else:
            self._grpc_options = dict()
        self._ssl_target_name = None
        self._tls_ca_certs_path = tls_ca_cert_file
        self._client_key_path = client_key_file
        self._client_cert_path = client_cert_file
        self._channel = create_grpc_channel(self._endpoint, tls_ca_cert_file,
                                            client_key_file,
                                            client_cert_file, opts)
        self._orderer_client = ab_pb2_grpc.AtomicBroadcastStub(self._channel)
示例#5
0
 def init_with_bundle(self, info):
     """
     Init the peer with given info dict
     :param info: Dict including all info, e.g., endpoint, grpc option
     :return: True or False
     """
     try:
         self._endpoint = info['url']
         self._grpc_options = info['grpcOptions']
         self._tls_ca_certs_path = info['tlsCACerts']['path']
         self._ssl_target_name = self._grpc_options[
             'ssl-target-name-override']
         self._channel = create_grpc_channel(
             self._endpoint,
             self._tls_ca_certs_path,
             opts=(('grpc.ssl_target_name_override',
                    self._ssl_target_name), ))
         self._orderer_client = ab_pb2_grpc.AtomicBroadcastStub(
             self._channel)
     except KeyError:
         return False
     return True
示例#6
0
    def __init__(self, name='orderer', endpoint=DEFAULT_ORDERER_ENDPOINT,
                 tls_ca_cert_file=None, client_key_file=None,
                 client_cert_file=None, opts=None):
        """
        endpoint: 특정한 grpc 채널 주소, default=DEFAULT_ORDERER_ENDPOINT
        opts: grpc 추가설정 튜플((key, val),)
        """
        self._name = name
        self._endpoint = endpoint
        if opts:
            self._grpc_options = {key: value for (key, value) in opts}
        else:
            self._grpc_options = dict()

        self._ssl_target_name = None
        self._tls_ca_certs_path = tls_ca_cert_file
        self._client_key_path = client_key_file
        self._client_cert_path = client_cert_file
        self._channel = create_grpc_channel(self._endpoint, tls_ca_cert_file,
                                            client_key_file,
                                            client_cert_file, opts)
        self._orderer_client = ab_pb2_grpc.AtomicBroadcastStub(self._channel)