kelunik / acme

Async ACME library written in PHP based on the Amp concurrency framework.
MIT License
121 stars 18 forks source link

Support for generating EC keys #22

Closed Ayesh closed 7 years ago

Ayesh commented 7 years ago

Hi Niklas, I have been using acme-client for a long time, and it is working really great! Since PHP 7.1 is released with EC key support (#14), I tried to add support.

I had to make some PHPDoc changes to make the KeyGenerator explaining that it can be used with other types of keys as well. In the OpenSSLKeyGenerator, it now supports OPENSSL_KEYTYPE_RSA and OPENSSL_KEYTYPE_EC, with different validations for each type.

For some reason, the EC key generation requires the $key_options['private_key_bits'] key to be set and larger than 384, hence the $key_options['private_key_bits'] = 2048; line in the EC switch case.

I tried running the tests myself (without a luck). I'd be grateful if you could provide an insight. I tested the key generation part by hand, and it did work well.

$gen = new \Kelunik\Acme\OpenSSLKeyGenerator();
$pair = $gen->generate('prime256v1', OPENSSL_KEYTYPE_EC);

Thank you very much.

kelunik commented 7 years ago

Thanks for the PR! I already wanted to have a look at EC, but didn't really find time for it. I'll try to have a look in the coming days. :-)