Skip to content

Add ZMQ Curve for transport encryption#1110

Open
krassowski wants to merge 21 commits into
jupyter:mainfrom
krassowski:add-curve-encryption
Open

Add ZMQ Curve for transport encryption#1110
krassowski wants to merge 21 commits into
jupyter:mainfrom
krassowski:add-curve-encryption

Conversation

@krassowski
Copy link
Copy Markdown
Member

@krassowski krassowski commented May 5, 2026

References

Code changes

Follows ipyparallel approach (ipython/ipyparallel#553)

  • Tests
  • Add curve_serverkey handling to heartbeat channel
  • Pass curve keys from connection file to the socket (implemented at mixing level)

@Carreau Carreau self-requested a review May 5, 2026 16:35
Copy link
Copy Markdown
Member

@Carreau Carreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most failing test seem to be an issue with history DB on IPython, i'm not sure they are related.

Done only a cursory review, I need to wrap my head around everything.

Comment thread jupyter_client/client.py Outdated
Comment thread jupyter_client/connect.py Outdated
Comment thread jupyter_client/channels.py
Comment thread jupyter_client/connect.py
Comment thread tests/test_transport_security.py Outdated
Comment thread tests/test_transport_security.py
@Carreau
Copy link
Copy Markdown
Member

Carreau commented May 6, 2026

+1 in general, this is a relatively small patch I was expecting more.

@Carreau
Copy link
Copy Markdown
Member

Carreau commented May 6, 2026

314t failures are due to msgpack/msgpack-python#613, msgpack is not free-threaded compatible yet, I'll send a PR that remove 314t testing.

@Carreau Carreau force-pushed the add-curve-encryption branch from d2a7b2b to e284a48 Compare May 6, 2026 11:58
@Carreau
Copy link
Copy Markdown
Member

Carreau commented May 6, 2026

(rebased on main to show less failures)

@krassowski krassowski force-pushed the add-curve-encryption branch from e284a48 to 6f06bc5 Compare May 6, 2026 12:05
Comment thread jupyter_client/client.py Outdated
"'curve_serverkey' parameter. Upgrade the heartbeat channel "
"class or disable CurveZMQ encryption."
)
raise RuntimeError(msg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread jupyter_client/client.py Outdated
self.context,
self.session,
url,
**({"curve_serverkey": self._curve_publickey} if hb_supports_curve else {}),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That triggers me to want to resume working on a pep for undefined/void parameter that is striped when calling function.

Comment thread jupyter_client/client.py Outdated
"'curve_serverkey' parameter. Upgrade the heartbeat channel "
"class or disable CurveZMQ encryption."
)
raise RuntimeError(msg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to inspect for hb_supports_curve, since we can pass the argument if it's required and let the standard unsupported argument error raise:

hb_kwargs = {}
if self._curve_publickey:
    hb_kwargs["curve_serverkey"] = self._curve_publickey
...
hb_channel_class(...**hb_kwargs)

but fine if you want to keep the more detailed error. But if you hit that error, a lot of other things are not going to work before we get to the hb channel, I think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with both; as long as we know there are some backward compatibility story here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 8b5d6d6 work?

@krassowski krassowski marked this pull request as ready for review May 9, 2026 08:23
Comment on lines +179 to +181
transport_encryption = bool(
kwargs.pop("transport_encryption", getattr(km, "transport_encryption", False))
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking for myself,

It that bool for type annotation to not fail ?
Should be more conservative and check that it actually is a bool (or None), we get back, and not any other non-falsy vallue ? Or are we thinking the ks.transport_encryption could one day become Enums of different type of encryption ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are we thinking the ks.transport_encryption could one day become Enums of different type of encryption

Yes, this is exactly why I called it transport_encryption (rather than enable_transport_encryption or transport_encryption_on).

Should be more conservative and check that it actually is a bool (or None), we get back, and not any other non-falsy vallue

Maybe for now? I do not have a strong opinion but happy to make this change.

Comment thread jupyter_client/provisioning/local_provisioner.py
Comment thread jupyter_client/client.py
Comment thread jupyter_client/connect.py
Comment thread jupyter_client/connect.py
Comment thread jupyter_client/manager.py Outdated
@Carreau
Copy link
Copy Markdown
Member

Carreau commented May 10, 2026

I can help trying and writing some of the suggestion if you like to, I'm just doing a quick review on Sunday between two other things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support encryption for the kernel protocol over ZMQ

3 participants