feat: add PrincipalId and ic_pem_identity crate#450
Conversation
Sign messages and allow for PEM files to be read and used to sign. In order to reduce dependencies, MessageWithSender and SignedMessage now are not generics.
|
Notes to discuss:
Other notes (to self mainly): When receiving a key file we usually validate it on the spot as containing the right curve etc. P.S. I would prefer we do not block ourselves or code on the replica behaviour. Adding more blockers does not help. |
|
P.S. Thank you for the time you took to share this example, Hans, with your thoughts! |
|
Hmm, also the principal should only be constructible by the signer -- hence placing it internally originally. The agent similarly to the handler see it as a Blob. |
I don't agree with that. They are blobs, so they can be constructed by anyone. They're also part of the public spec so they should be in VALID principal IDs should be constructible by either the signer or the public API (e.g. when you get one from IDL). But the type itself should still be part of the crate responsible for exchanging with the replica. It's an agent type. |
|
Let me take some time to answer your points;
Keys are touched only in the
That's fine for this PR. Stay focused. We can add this PR, which took me 3 hours, then add error messaging for users in another PR if they don't use identity, then add the dfx.json configuration for identity, then make identity mandatory. That's 5 PRs that should be spaced on 2 releases (we probably want to tell the user identity will be required). Right now we have none of that, not even in an optional manner.
We can change that code later, and have the PEM in the global
A prompt can be added later.
Not default. If SSH does not have that as default, I think we'll be fine.
There are 2 files changed: the argument which is part of all canister commands (and honestly that's all we need), and generating a new key which is in the new command. The environment changes are for allowing overloading the signer. |
It is actually. You get prompted for a passphrase. You can pick it to be empty, but I hope we don't promote that. |
I agree. I do that in #438 though. Can you look? |
## Changelog for advisory-db: Branch: master Commits: [rustsec/advisory-db@6e48979d...0ad26bc7](rustsec/advisory-db@6e48979...0ad26bc) * [`5751a5f4`](rustsec/advisory-db@5751a5f) CI: bump rustsec-admin to v0.3.0-pre2 ([RustSec/advisory-db#438](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/438)) * [`65441901`](rustsec/advisory-db@6544190) Add unmaintained crate advisory for stdweb ([RustSec/advisory-db#439](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/439)) * [`acc73d95`](rustsec/advisory-db@acc73d9) CI: bump rustsec-admin to v0.3.0-pre3 ([RustSec/advisory-db#440](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/440)) * [`691a7504`](rustsec/advisory-db@691a750) Assigned RUSTSEC-2020-0056 to stdweb ([RustSec/advisory-db#441](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/441)) * [`8505c957`](rustsec/advisory-db@8505c95) Add unmaintained crate advisory for `block-cipher` ([RustSec/advisory-db#442](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/442)) * [`fa616899`](rustsec/advisory-db@fa61689) Assigned RUSTSEC-2020-0057 to block-cipher ([RustSec/advisory-db#443](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/443)) * [`5c9ebbfa`](rustsec/advisory-db@5c9ebbf) Add unmaintained crate advisory for `stream-cipher` ([RustSec/advisory-db#444](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/444)) * [`218de91a`](rustsec/advisory-db@218de91) Assigned RUSTSEC-2020-0058 to stream-cipher ([RustSec/advisory-db#445](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/445)) * [`681a2040`](rustsec/advisory-db@681a204) Add advisory for notable UB fix in libpulse-binding v2.6.0 ([RustSec/advisory-db#435](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/435)) * [`1e48ac39`](rustsec/advisory-db@1e48ac3) Assigned RUSTSEC-2019-0038 to libpulse-binding ([RustSec/advisory-db#446](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/446)) * [`59bee556`](rustsec/advisory-db@59bee55) Add advisory for use-after-frees fixed in libpulse-binding v1.2.1 ([RustSec/advisory-db#433](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/433)) * [`146de2d8`](rustsec/advisory-db@146de2d) Assigned RUSTSEC-2018-0021 to libpulse-binding ([RustSec/advisory-db#447](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/447)) * [`3b1f08f2`](rustsec/advisory-db@3b1f08f) Unyank RUSTSEC-2020-0011 ([RustSec/advisory-db#448](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/448)) * [`3796cc00`](rustsec/advisory-db@3796cc0) README.md: point chat badge to Zulip ([RustSec/advisory-db#449](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/449)) * [`1bf68e0d`](rustsec/advisory-db@1bf68e0) RUSTSEC-2020-0015: use wildcards in version req ([RustSec/advisory-db#450](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/450)) * [`67a2144b`](rustsec/advisory-db@67a2144) RUSTSEC-2020-0015: remove wildcards ([RustSec/advisory-db#451](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/451)) * [`0ad26bc7`](rustsec/advisory-db@0ad26bc) Bump `rustsec-admin` to v0.3.0 ([RustSec/advisory-db#452](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/452))
## Changelog for advisory-db: Branch: master Commits: [rustsec/advisory-db@6e48979d...0ad26bc7](rustsec/advisory-db@6e48979...0ad26bc) * [`5751a5f4`](rustsec/advisory-db@5751a5f) CI: bump rustsec-admin to v0.3.0-pre2 ([RustSec/advisory-db#438](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/438)) * [`65441901`](rustsec/advisory-db@6544190) Add unmaintained crate advisory for stdweb ([RustSec/advisory-db#439](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/439)) * [`acc73d95`](rustsec/advisory-db@acc73d9) CI: bump rustsec-admin to v0.3.0-pre3 ([RustSec/advisory-db#440](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/440)) * [`691a7504`](rustsec/advisory-db@691a750) Assigned RUSTSEC-2020-0056 to stdweb ([RustSec/advisory-db#441](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/441)) * [`8505c957`](rustsec/advisory-db@8505c95) Add unmaintained crate advisory for `block-cipher` ([RustSec/advisory-db#442](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/442)) * [`fa616899`](rustsec/advisory-db@fa61689) Assigned RUSTSEC-2020-0057 to block-cipher ([RustSec/advisory-db#443](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/443)) * [`5c9ebbfa`](rustsec/advisory-db@5c9ebbf) Add unmaintained crate advisory for `stream-cipher` ([RustSec/advisory-db#444](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/444)) * [`218de91a`](rustsec/advisory-db@218de91) Assigned RUSTSEC-2020-0058 to stream-cipher ([RustSec/advisory-db#445](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/445)) * [`681a2040`](rustsec/advisory-db@681a204) Add advisory for notable UB fix in libpulse-binding v2.6.0 ([RustSec/advisory-db#435](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/435)) * [`1e48ac39`](rustsec/advisory-db@1e48ac3) Assigned RUSTSEC-2019-0038 to libpulse-binding ([RustSec/advisory-db#446](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/446)) * [`59bee556`](rustsec/advisory-db@59bee55) Add advisory for use-after-frees fixed in libpulse-binding v1.2.1 ([RustSec/advisory-db#433](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/433)) * [`146de2d8`](rustsec/advisory-db@146de2d) Assigned RUSTSEC-2018-0021 to libpulse-binding ([RustSec/advisory-db#447](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/447)) * [`3b1f08f2`](rustsec/advisory-db@3b1f08f) Unyank RUSTSEC-2020-0011 ([RustSec/advisory-db#448](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/448)) * [`3796cc00`](rustsec/advisory-db@3796cc0) README.md: point chat badge to Zulip ([RustSec/advisory-db#449](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/449)) * [`1bf68e0d`](rustsec/advisory-db@1bf68e0) RUSTSEC-2020-0015: use wildcards in version req ([RustSec/advisory-db#450](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/450)) * [`67a2144b`](rustsec/advisory-db@67a2144) RUSTSEC-2020-0015: remove wildcards ([RustSec/advisory-db#451](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/451)) * [`0ad26bc7`](rustsec/advisory-db@0ad26bc) Bump `rustsec-admin` to v0.3.0 ([RustSec/advisory-db#452](http://r.duckduckgo.com/l/?uddg=https://github.com/RustSec/advisory-db/issues/452))
Sign messages and allow for PEM files to be read and used to sign.
In order to reduce dependencies, MessageWithSender and SignedMessage
now are not generics.
Notes
This PR actually does not work because the replica isn't up to spec. But it can serve as a starting point once the replica is fixed.