当前位置: 首页>>代码示例>>Python>>正文


Python grpc.composite_channel_credentials方法代码示例

本文整理汇总了Python中grpc.composite_channel_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python grpc.composite_channel_credentials方法的具体用法?Python grpc.composite_channel_credentials怎么用?Python grpc.composite_channel_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grpc的用法示例。


在下文中一共展示了grpc.composite_channel_credentials方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: lnd_client

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def lnd_client(self):
        if self._lnd_client is not None:
            return self._lnd_client
        auth_credentials = grpc.metadata_call_credentials(
            self.metadata_callback)

        credentials = grpc.composite_channel_credentials(
            self.get_cert_credentials(),
            auth_credentials)

        grpc_channel = grpc.secure_channel(
            f'{self.grpc_host}:{self.grpc_port}',
            credentials,
            options=self.grpc_options
        )
        self._lnd_client = lnrpc.LightningStub(grpc_channel)
        return self._lnd_client 
开发者ID:lightning-power-users,项目名称:node-launcher,代码行数:19,代码来源:lnd_client.py

示例2: combined_credentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def combined_credentials(self) -> grpc.CallCredentials:
        """
        Combine ssl and macaroon credentials
        :return: grpc.composite_channel_credentials
        """
        cert_creds = grpc.ssl_channel_credentials(self.tls_cert)
        auth_creds = grpc.metadata_call_credentials(self.metadata_callback)
        return grpc.composite_channel_credentials(cert_creds, auth_creds) 
开发者ID:willcl-ark,项目名称:lnd_grpc,代码行数:10,代码来源:base_client.py

示例3: get_rpc_channel

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def get_rpc_channel(host="localhost", port="10009", cert_path=None, macaroon_path=None):
    if not macaroon_path:
        raise Exception("need to specify a macaroon path!")

    def metadata_callback(context, callback):
        # for more info see grpc docs
        callback([('macaroon', macaroon)], None)

    # Due to updated ECDSA generated tls.cert we need to let gprc know that
    # we need to use that cipher suite otherwise there will be a handshake
    # error when we communicate with the lnd rpc server.
    os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA'

    if not cert_path:
        cert_path = os.path.expanduser('~/.lnd/tls.cert')

    assert isfile(cert_path) and os.access(cert_path, os.R_OK), \
        "File {} doesn't exist or isn't readable".format(cert_path)
    cert = open(cert_path, 'rb').read()

    with open(macaroon_path, 'rb') as f:
        macaroon_bytes = f.read()
        macaroon = codecs.encode(macaroon_bytes, 'hex')

    # build ssl credentials using the cert the same as before
    cert_creds = grpc.ssl_channel_credentials(cert)

    # now build meta data credentials
    auth_creds = grpc.metadata_call_credentials(metadata_callback)

    # combine the cert credentials and the macaroon auth credentials
    # such that every call is properly encrypted and authenticated
    combined_creds = grpc.composite_channel_credentials(cert_creds, auth_creds)

    # finally pass in the combined credentials when creating a channel
    return grpc.secure_channel('{}:{}'.format(host, port), combined_creds) 
开发者ID:rootzoll,项目名称:raspiblitz,代码行数:38,代码来源:client.py

示例4: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
    sslCred = grpc.ssl_channel_credentials()

    authCred = grpc.metadata_call_credentials(credentials)

    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# gRPC channel 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:grpc.py

示例5: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
	sslCred = grpc.ssl_channel_credentials()
	authCred = grpc.metadata_call_credentials(credentials)
	return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceStream 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:10,代码来源:ex4_getText2VoiceStream.py

示例6: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
    sslCred = grpc.ssl_channel_credentials()

    authCred = grpc.metadata_call_credentials(credentials)

    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ### 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:10,代码来源:ex2_getVoice2Text.py

示例7: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
	sslCred = grpc.ssl_channel_credentials()

	authCred = grpc.metadata_call_credentials(credentials)

	return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# DIALOG : queryByText 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex5_queryText.py

示例8: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
	sslCred = grpc.ssl_channel_credentials()

	authCred = grpc.metadata_call_credentials(credentials)

	return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceUrl 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex3_getText2VoiceUrl.py

示例9: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
	with open('../data/ca-bundle.pem', 'rb') as f:
		trusted_certs = f.read()
	sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)

	authCred = grpc.metadata_call_credentials(credentials)

	return grpc.composite_channel_credentials(sslCred, authCred)

### KWS 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:proj2_yt_mvp.py

示例10: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
    with open('/home/pi/ai-makers-kit/data/ca-bundle.pem', 'rb') as f:
        trusted_certs = f.read()
    sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
    authCred = grpc.metadata_call_credentials(credentials)
    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceStream 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex4_getText2VoiceStream.py

示例11: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
    with open('../data/ca-bundle.pem', 'rb') as f:
        trusted_certs = f.read()
    sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)

    authCred = grpc.metadata_call_credentials(credentials)

    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

### STT 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:14,代码来源:ex2_getVoice2Text.py

示例12: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
    with open('../data/ca-bundle.pem', 'rb') as f:
        trusted_certs = f.read()
    sslCred = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
    authCred = grpc.metadata_call_credentials(credentials)
    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ###

# TTS : getText2VoiceStream 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:12,代码来源:ex4_getText2VoiceStream.py

示例13: getCredentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def getCredentials():
    sslCred = grpc.ssl_channel_credentials()
    authCred = grpc.metadata_call_credentials(credentials)
    return grpc.composite_channel_credentials(sslCred, authCred)

### END OF COMMON ### 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:8,代码来源:user_auth.py

示例14: get_api_client

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def get_api_client(api_endpoint=None):
    server_info = _get_server_info(api_endpoint=api_endpoint)
    _handle_server_info(server_info)
    channel_creds = grpc.ssl_channel_credentials()
    credentials = auth.CredentialsStore().read_credentials()
    if credentials:
        channel_creds = grpc.composite_channel_credentials(
            channel_creds, auth.id_token_call_credentials(credentials)
        )
    channel = grpc.secure_channel(
        server_info.api_server.endpoint, channel_creds
    )
    return export_service_pb2_grpc.TensorBoardExporterServiceStub(channel) 
开发者ID:tensorflow,项目名称:tensorboard,代码行数:15,代码来源:experiment_from_dev.py

示例15: generate_credentials

# 需要导入模块: import grpc [as 别名]
# 或者: from grpc import composite_channel_credentials [as 别名]
def generate_credentials(cert, macaroon):
    """Create composite channel credentials using cert and macaroon metatdata"""
    # create cert credentials from the tls.cert file
    cert_creds = grpc.ssl_channel_credentials(cert)

    # build meta data credentials
    metadata_plugin = MacaroonMetadataPlugin(macaroon)
    auth_creds = grpc.metadata_call_credentials(metadata_plugin)

    # combine the cert credentials and the macaroon auth credentials
    # such that every call is properly encrypted and authenticated
    return grpc.composite_channel_credentials(cert_creds, auth_creds) 
开发者ID:adrienemery,项目名称:lnd-grpc-client,代码行数:14,代码来源:common.py


注:本文中的grpc.composite_channel_credentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。