Skip to content
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

Implement Clone for AccountCredentials #61

Open
h33p opened this issue Aug 8, 2024 · 3 comments
Open

Implement Clone for AccountCredentials #61

h33p opened this issue Aug 8, 2024 · 3 comments

Comments

@h33p
Copy link

h33p commented Aug 8, 2024

Currently, AccountCredentials only implements Serialize, and Deserialize, but cloning them may be useful for recreating ACME client instances. We currently do the following under the hood:

fn clone_creds(creds: &AccountCredentials) -> AccountCredentials {
    serde_json::from_str(&serde_json::to_string(&creds).unwrap()).unwrap()
}

However, I feel like this is unnecessary, and it would be better to be able to just clone the creds.

@djc
Copy link
Owner

djc commented Aug 8, 2024

Why do you need to clone the credentials? What's the use case?

@h33p
Copy link
Author

h33p commented Aug 8, 2024

Why do you need to clone the credentials? What's the use case?

Whenever I need to recreate Account.

Account::from_credentials consumes the credentials object. Sometimes, ACME server returns an error when acquiring a session, and thus, a retry is needed. Alternatively, I experienced a case where the account session stopped working after some time, which could be fixed by recreating the Account object, which once again, requires me to clone the credentials.

@djc
Copy link
Owner

djc commented Aug 8, 2024

Okay, I'd rather fix the cases where you need to recreate an account. It is on purpose that there's no Clone implementation for AccountCredentials, in order to make it harder to accidentally leak private key data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants