-
Notifications
You must be signed in to change notification settings - Fork 312
Add ZMQ Curve for transport encryption #1110
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
base: main
Are you sure you want to change the base?
Changes from all commits
1d2255d
2e84f9c
d2a7b2b
fb28ce5
683aa8e
f73224d
6f06bc5
42420c6
81a2daa
460d7c5
71fdbf9
9dc0b71
7deb5e4
8b5d6d6
68a485a
129fe04
f3a4b97
c8e1b8a
772f4b4
2a5f8ee
242c6b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,8 @@ | |
| import sys | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| import zmq | ||
|
|
||
| from ..connect import KernelConnectionInfo, LocalPortCache | ||
| from ..launcher import launch_kernel | ||
| from ..localinterfaces import is_local_ip, local_ips | ||
|
|
@@ -174,6 +176,11 @@ async def pre_launch(self, **kwargs: Any) -> dict[str, Any]: | |
| # This should be considered temporary until a better division of labor can be defined. | ||
| km = self.parent | ||
| if km: | ||
| transport_encryption = bool( | ||
| kwargs.pop("transport_encryption", getattr(km, "transport_encryption", False)) | ||
| ) | ||
|
Comment on lines
+179
to
+181
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking for myself, It that bool for type annotation to not fail ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, this is exactly why I called it
Maybe for now? I do not have a strong opinion but happy to make this change. |
||
| curve_publickey: bytes | None = None | ||
| curve_secretkey: bytes | None = None | ||
| if km.transport == "tcp" and not is_local_ip(km.ip): | ||
| msg = ( | ||
| "Can only launch a kernel on a local interface. " | ||
|
|
@@ -196,11 +203,23 @@ async def pre_launch(self, **kwargs: Any) -> dict[str, Any]: | |
| km.hb_port = lpc.find_available_port(km.ip) | ||
| km.control_port = lpc.find_available_port(km.ip) | ||
| self.ports_cached = True | ||
|
|
||
| if transport_encryption: | ||
| curve_publickey, curve_secretkey = zmq.curve_keypair() | ||
| km.curve_publickey = curve_publickey | ||
| km.curve_secretkey = curve_secretkey | ||
| if "env" in kwargs: | ||
| jupyter_session = kwargs["env"].get("JPY_SESSION_NAME", "") | ||
| km.write_connection_file(jupyter_session=jupyter_session) | ||
| km.write_connection_file( | ||
| jupyter_session=jupyter_session, | ||
| curve_publickey=curve_publickey, | ||
| curve_secretkey=curve_secretkey, | ||
| ) | ||
| else: | ||
| km.write_connection_file() | ||
| km.write_connection_file( | ||
| curve_publickey=curve_publickey, | ||
| curve_secretkey=curve_secretkey, | ||
| ) | ||
|
Carreau marked this conversation as resolved.
|
||
| self.connection_info = km.get_connection_info() | ||
|
|
||
| kernel_cmd = km.format_kernel_cmd( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.