yourivw / LEClient

An easy-to-use PHP ACME v2 client library, designed to be used with LetsEncrypt.
MIT License
204 stars 98 forks source link

Multiple accounts #55

Closed viharm closed 6 years ago

viharm commented 6 years ago

This is a good library and provides excellent abstraction for development work.

I needed several trials to get through a full validation cycle, but that may be my own limitation.

I am creating an app which utilises this library, and want to include functionality for multiple Let's Encrypt accounts.

Currently, I believe the single-account functionality leads to the same key pair being used for all $emails specified in the class initiation and account functions

Is there a way to store multiple accounts keys? Probably based on email address? Like... user-domain-tld_privkey.pkcs8.pem user-domain-tld_pubkey.pem

viharm commented 6 years ago

I guess the ability to specify an account key will suffice

viharm commented 6 years ago

This functionality is built into the client constructor at https://github.com/yourivw/LEClient/blob/a9ce9f2c133a379d4a7137d80ed5881e50a7bdf8/src/LEClient.php#L67

Fourth and fifth arguments are for the certificate keys and for the account keys respectively

The constructor checks if the certificate keys argument is an array at https://github.com/yourivw/LEClient/blob/a9ce9f2c133a379d4a7137d80ed5881e50a7bdf8/src/LEClient.php#L104, and then check for the following keys

* `certificate`
* `private_key`
* `order`
* `public_key`

Similarly it checks if the account keys argument is an array at https://github.com/yourivw/LEClient/blob/a9ce9f2c133a379d4a7137d80ed5881e50a7bdf8/src/LEClient.php#L138, and then checks for the following array keys

* `private_key`
* `public_key`

This allows significant flexibility as my app can have multiple accounts and specify which account to query.