def get_secure_channel(crt_file, key_file, port=50051):
    """Try to connect over a secure channel."""

    creds = grpc.ssl_channel_credentials(
        root_certificates=open(str(crt_file), 'rb').read(),
        private_key=open(str(key_file), 'rb').read(),
        certificate_chain=open(str(crt_file), 'rb').read())

    address = "{}:{}".format(socket.gethostname(), port)
    channel = grpc.secure_channel(address, creds)
    return channel
Try to connect over a secure channel.