unixcharles / acme-client

A Ruby client for the letsencrypt's ACME protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mention Client.new's jwk: keyword

IotaSpencer opened this issue · comments

I've actually spent a few days trying to find a way to convert to pem just to find out by browsing the source that you already implemented that way. It would be nice if the jwk keyword was mentioned in the readme.

I've actually spent a few days trying to find a way to convert to pem just to find out by browsing the source that you already implemented that way.

What way?

It would be nice if the jwk keyword was mentioned in the readme.

I did not document because the use case are limited but feel free to open a PR.

Considering the private_key.json for letsencrypt/certbot is a jwk, it may very well be a limited use case, but its usage inside of trying to use ruby to make an alternative to the certbot executable, would be much more needed, since one can run certbot once, or hopefully my gem to create a key, then use similar means to talk to their servers.

While I haven't been able to make the jwk: keyword work in a way that doesn't raise an exception, which that would be.

root@web:~# ./acme_client 
Traceback (most recent call last):
	7: from ./acme_client:18:in `<main>'
	6: from /var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client.rb:98:in `kid'
	5: from /var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client.rb:88:in `account'
	4: from /var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client.rb:251:in `post'
	3: from /var/lib/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/connection.rb:175:in `post'
	2: from /var/lib/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
	1: from /var/lib/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
/var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client/faraday_middleware.rb:19:in `call': undefined method `jws' for #<Hash:0x000056513efb3a70> (NoMethodError)
root@web:~# nano acme_client 
root@web:~# ./acme_client 
Traceback (most recent call last):
	7: from ./acme_client:18:in `<main>'
	6: from /var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client.rb:98:in `kid'
	5: from /var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client.rb:88:in `account'
	4: from /var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client.rb:251:in `post'
	3: from /var/lib/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/connection.rb:175:in `post'
	2: from /var/lib/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
	1: from /var/lib/gems/2.5.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
/var/lib/gems/2.5.0/gems/acme-client-2.0.2/lib/acme/client/faraday_middleware.rb:19:in `call': undefined method `jws' for #<String:0x000055cf9137cf88> (NoMethodError)

First is using jwk = JSON.load(File.open('/path/to/private_key.json'))
Second is using jwk = File.open('/path/to/private_key.json')

So I'll add what worked for me, which was using JOSE to load the JWK and then outputting the raw key to private_key:

Pull request for jwk mention is #158