-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect to a server with curve server key only #1706
Comments
This isn't a pyzmq issue, but I believe you still need to set a private and public in order to send encrypted messages. That means also setting Failure to authenticate with zmq generally means just silently not connecting (as if the peer is not there) rather than error, because zmq connect is async there's nowhere to raise. |
@minrk It still doesnt work. In c# I just use
I though doing the same here would work also. I have changed it to
|
I'm not sure. That certainly looks right. Here's an example that works (all in Python). Maybe it will help you debug: from threading import Thread
import zmq
server_public, server_private = zmq.curve_keypair()
url = "tcp://127.0.0.1:5555"
def server():
with zmq.Context() as ctx:
with ctx.socket(zmq.ROUTER) as s:
s.curve_secretkey = server_private
s.curve_publickey = server_public
s.curve_server = 1
s.rcvtimeo = 3000 # give up after 3 seconds
s.bind(url)
msg = s.recv_multipart()
print(f"server: received {msg[1:]} from {msg[0]}")
s.send_multipart([msg[0], b"ack"])
def client():
client_public, client_private = zmq.curve_keypair()
with zmq.Context() as ctx:
with ctx.socket(zmq.DEALER) as s:
s.curve_secretkey = client_private
s.curve_publickey = client_public
s.curve_serverkey = server_public
s.linger = 0
s.rcvtimeo = 3000 # give up after 3 seconds
s.connect(url)
msg = [b"hello"]
print(f"client: sending {msg}")
s.send_multipart(msg)
reply = s.recv_multipart()
print(f"client: received {reply}")
# start server
t = Thread(target=server, daemon=True)
t.start()
# start client
client()
# wait for server cleanup
t.join() The only thing I can think of is possible inconsistencies in base64 handling (you might show the actual bytes to compare - curve keys are already z85-encoded, so double-encoding them with base64 is unusual since they are valid ASCII already), or making sure to set all the curve parameters before calling connect/bind. |
Is it possible to connect to a zmq server with only CURVE_SERVERKEY?
The key is similar to "masdasdasdsadasdQWEqwedsa2+BrhQ=" and im trying to use it to connect to a zmq server
self.socket.setsockopt(zmq.CURVE_SERVERKEY, z85.encode(base64.b64decode(self.server_public_key)))
It gives me no error and it doesnt connect.
The text was updated successfully, but these errors were encountered: