def addClientAuth( self, socket: zmq.Socket ): self.logger.info( f"Adding ZMQ client auth using keys from dir: {self.cert_dir}") client_secret_file = os.path.join( self.secret_keys_dir, "client.key_secret") client_public, client_secret = zmq.auth.load_certificate(client_secret_file) socket.curve_secretkey = client_secret socket.curve_publickey = client_public server_public_file = os.path.join( self.public_keys_dir, "server.key") server_public, _ = zmq.auth.load_certificate(server_public_file) socket.curve_serverkey = server_public
def _set_curve_keypair(self, socket: zmq.Socket): """ Generate a client keypair using CURVE encryption mechanism, and set the server key for encryption. :param socket: (zmq.Socket) The socket to set CURVE key. """ client_public, client_secret = zmq.curve_keypair() socket.curve_publickey = client_public socket.curve_secretkey = client_secret socket.setsockopt_string(zmq.CURVE_SERVERKEY, self._SERVER_ZMQ_ENCRYPTION_KEY)