acme-client 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 056d35b4c628c93ad60a134ab46044cdbc5f9e38
4
- data.tar.gz: d90a2d072631c7f68e9ea783e1a8878bc844314f
3
+ metadata.gz: 5bcc6e2a6458b03064bb7021971717fd63dc0f2a
4
+ data.tar.gz: 626fa36167c44f46612a9008a600a0e48a599e3d
5
5
  SHA512:
6
- metadata.gz: e8b93b207b8016d1464f9e9f4fa20e7e303554eee08ac01eed069de34db084318dfb440e78d1ef07978bbd91ae385c8eaae3350b18b5f806c8a170d6bb776a0a
7
- data.tar.gz: a23f0b2e33d7434abfe4e77bcb51e4d4d867cff629781f820704a484c89c0a6abfab028099542936c539b81c0e11d0abd9a05da4a96485425a91cb1034847ba0
6
+ metadata.gz: 3c4334775f5f2085dc8c5d9f93814204bc31f1fa16a887618f76f15711945ad065d87fd937ab03bdeda0f8a55326cee36768a90338b8ec5fdd58f559771f4020
7
+ data.tar.gz: 64beae8555a63fdccbadd33d7c0d09a06f6ec705e692fdb05b8d5984259010a8d956a6190d0715bfa6b5c92c0323ac2c551ffe2b3584a41ca8e3fa476550eec6
data/README.md CHANGED
@@ -37,8 +37,8 @@ private_key = OpenSSL::PKey::RSA.new(4096)
37
37
  endpoint = 'https://acme-v01.api.letsencrypt.org/'
38
38
 
39
39
  # Initialize the client
40
- require 'acme/client'
41
- client = Acme::Client.new(private_key: private_key, endpoint: endpoint)
40
+ require 'acme-client'
41
+ client = Acme::Client.new(private_key: private_key, endpoint: endpoint, connection_options: { request: { open_timeout: 5, timeout: 5 } })
42
42
 
43
43
  # If the private key is not known to the server, we need to register it for the first time.
44
44
  registration = client.register(contact: 'mailto:contact@example.com')
data/lib/acme-client.rb CHANGED
@@ -1,5 +1,3 @@
1
- module Acme; class Client; end; end
2
-
3
1
  require 'faraday'
4
2
  require 'json'
5
3
  require 'json/jwt'
@@ -7,11 +5,13 @@ require 'openssl'
7
5
  require 'digest'
8
6
  require 'forwardable'
9
7
 
8
+ module Acme; end
9
+
10
+ require 'acme/client'
10
11
  require 'acme/client/certificate'
11
12
  require 'acme/client/certificate_request'
12
13
  require 'acme/client/self_sign_certificate'
13
14
  require 'acme/client/crypto'
14
- require 'acme/client'
15
15
  require 'acme/client/resources'
16
16
  require 'acme/client/faraday_middleware'
17
17
  require 'acme/client/error'
data/lib/acme/client.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'acme-client'
2
-
3
1
  class Acme::Client
4
2
  DEFAULT_ENDPOINT = 'http://127.0.0.1:4000'.freeze
5
3
  DIRECTORY_DEFAULT = {
@@ -9,8 +7,8 @@ class Acme::Client
9
7
  'revoke-cert' => '/acme/revoke-cert'
10
8
  }.freeze
11
9
 
12
- def initialize(private_key:, endpoint: DEFAULT_ENDPOINT, directory_uri: nil)
13
- @endpoint, @private_key, @directory_uri = endpoint, private_key, directory_uri
10
+ def initialize(private_key:, endpoint: DEFAULT_ENDPOINT, directory_uri: nil, connection_options: {})
11
+ @endpoint, @private_key, @directory_uri, @connection_options = endpoint, private_key, directory_uri, connection_options
14
12
  @nonces ||= []
15
13
  load_directory!
16
14
  end
@@ -46,7 +44,7 @@ class Acme::Client
46
44
  }
47
45
 
48
46
  response = connection.post(@operation_endpoints.fetch('new-cert'), payload)
49
- ::Acme::Client::Certificate.new(OpenSSL::X509::Certificate.new(response.body), fetch_chain(response), csr)
47
+ ::Acme::Client::Certificate.new(OpenSSL::X509::Certificate.new(response.body), response.headers['location'], fetch_chain(response), csr)
50
48
  end
51
49
 
52
50
  def revoke_certificate(certificate)
@@ -62,7 +60,7 @@ class Acme::Client
62
60
  end
63
61
 
64
62
  def connection
65
- @connection ||= Faraday.new(@endpoint) do |configuration|
63
+ @connection ||= Faraday.new(@endpoint, **@connection_options) do |configuration|
66
64
  configuration.use Acme::Client::FaradayMiddleware, client: self
67
65
  configuration.adapter Faraday.default_adapter
68
66
  end
@@ -1,12 +1,13 @@
1
1
  class Acme::Client::Certificate
2
2
  extend Forwardable
3
3
 
4
- attr_reader :x509, :x509_chain, :request, :private_key
4
+ attr_reader :x509, :x509_chain, :request, :private_key, :url
5
5
 
6
6
  def_delegators :x509, :to_pem, :to_der
7
7
 
8
- def initialize(certificate, chain, request)
8
+ def initialize(certificate, url, chain, request)
9
9
  @x509 = certificate
10
+ @url = url
10
11
  @x509_chain = chain
11
12
  @request = request
12
13
  end
@@ -9,4 +9,7 @@ class Acme::Client::Error < StandardError
9
9
  class Acme::Tls < Acme::Client::Error; end
10
10
  class Unauthorized < Acme::Client::Error; end
11
11
  class UnknownHost < Acme::Client::Error; end
12
+ class Timeout < Acme::Client::Error; end
13
+ class RateLimited < Acme::Client::Error; end
14
+ class RejectedIdentifier < Acme::Client::Error; end
12
15
  end
@@ -10,6 +10,8 @@ class Acme::Client::FaradayMiddleware < Faraday::Middleware
10
10
  @env = env
11
11
  @env.body = crypto.generate_signed_jws(header: { nonce: pop_nonce }, payload: env.body)
12
12
  @app.call(env).on_complete { |response_env| on_complete(response_env) }
13
+ rescue Faraday::TimeoutError
14
+ raise Acme::Client::Error::Timeout
13
15
  end
14
16
 
15
17
  def on_complete(env)
@@ -1,5 +1,5 @@
1
1
  module Acme
2
2
  class Client
3
- VERSION = '0.3.1'.freeze
3
+ VERSION = '0.3.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acme-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Barbier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-06 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.4.5.1
202
+ rubygems_version: 2.5.1
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Client for the ACME protocol.