lucacasonato / acme2

A Tokio and OpenSSL based ACMEv2 client for Rust.
https://docs.rs/acme2
Other
22 stars 8 forks source link

Q: Is it safe to serialize and deserialize objects? #19

Open dacut opened 3 years ago

dacut commented 3 years ago

I see that many of the structs and enums derive Deserialize but not Serialize. Would it be safe to add Serialize to these objects?

What I'm trying to do: I'm trying to make an event-driven ACME interface (for serverless uses like AWS Lambda). Ideally, this wouldn't block while waiting for a challenge to be validated and a separate polling system (e.g. Step Functions) would drive this.

Doing this correctly requires (I think) snapshotting the current order, authorizations, and challenges (e.g. to JSON) and reconstituting them elsewhere.

I'm going to go ahead and try this myself, but was curious if you had any insight.

Thanks!

lucacasonato commented 2 years ago

No, they can not be safely snapshotted right now (calling a method on a snapshotted struct will throw).

I am happy to take a PR that lets you "re-hydrate" a snapshotted struct by de-serializing it and then calling a new .with_account() method that re-populates the account: Option<Arc<Account>> inner slot.