acme-client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +1 -1
- data/lib/acme/client.rb +1 -1
- data/lib/acme/crypto.rb +5 -1
- data/lib/acme/resources/authorization.rb +3 -3
- data/lib/acme/resources/challenges.rb +2 -1
- data/lib/acme/resources/challenges/base.rb +33 -0
- data/lib/acme/resources/challenges/http01.rb +20 -0
- data/lib/acme/version.rb +1 -1
- metadata +4 -3
- data/lib/acme/resources/challenges/simple_http.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db4de0115967af2794cdf73fbc564ba3207d07bb
|
4
|
+
data.tar.gz: a6e4dbafa02042fa3ebdf0c171a5f700770d000c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54827c5a1b93c079476b4ee7061d42d8a69c668063afd571887a040b063c362fc68f279fff2ebc9260b0bde0dd3d4af6b86b8f950385419f715bb6bb5f74f42
|
7
|
+
data.tar.gz: 368afee114cd978a13f764869f84c74fbd7df1177bed9ed8a25c3e675b2bb8e4f0de80c97bc3f3f6d061e4bd9c6d0c4a938f78cd1f16789e48907f721499a0a7
|
data/bin/console
CHANGED
data/lib/acme/client.rb
CHANGED
data/lib/acme/crypto.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Acme::Resources::Authorization
|
2
|
-
|
2
|
+
HTTP01 = Acme::Resources::Challenges::HTTP01
|
3
3
|
|
4
|
-
attr_reader :domain, :status, :
|
4
|
+
attr_reader :domain, :status, :http01
|
5
5
|
|
6
6
|
def initialize(client, response)
|
7
7
|
@client = client
|
@@ -14,7 +14,7 @@ class Acme::Resources::Authorization
|
|
14
14
|
def assign_challenges(challenges)
|
15
15
|
challenges.each do |attributes|
|
16
16
|
case attributes.fetch('type')
|
17
|
-
when '
|
17
|
+
when 'http-01' then @http01 = HTTP01.new(@client, attributes)
|
18
18
|
else
|
19
19
|
# no supported
|
20
20
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Acme::Resources::Challenges::Base
|
2
|
+
|
3
|
+
attr_reader :client, :status, :uri, :token, :error
|
4
|
+
|
5
|
+
def initialize(client, attributes)
|
6
|
+
@client = client
|
7
|
+
assign_attributes(attributes)
|
8
|
+
end
|
9
|
+
|
10
|
+
def verify_status
|
11
|
+
response = @client.connection.get(@uri)
|
12
|
+
|
13
|
+
assign_attributes(response.body)
|
14
|
+
@error = response.body['error']
|
15
|
+
status
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def authorization_key
|
21
|
+
"#{token}.#{crypto.thumbprint}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def assign_attributes(attributes)
|
25
|
+
@status = attributes.fetch('status', 'pending')
|
26
|
+
@uri = attributes.fetch('uri')
|
27
|
+
@token = attributes.fetch('token')
|
28
|
+
end
|
29
|
+
|
30
|
+
def crypto
|
31
|
+
@crypto ||= Acme::Crypto.new(@client.private_key)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Acme::Resources::Challenges::HTTP01 < Acme::Resources::Challenges::Base
|
2
|
+
CONTENT_TYPE = 'text/plain'
|
3
|
+
|
4
|
+
def content_type
|
5
|
+
CONTENT_TYPE
|
6
|
+
end
|
7
|
+
|
8
|
+
def file_content
|
9
|
+
authorization_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def filename
|
13
|
+
".well-known/acme-challenge/#{token}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def request_verification
|
17
|
+
response = client.connection.post(@uri, { resource: 'challenge', type: 'http-01', keyAuthorization: authorization_key })
|
18
|
+
response.success?
|
19
|
+
end
|
20
|
+
end
|
data/lib/acme/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Barbier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -183,7 +183,8 @@ files:
|
|
183
183
|
- lib/acme/resources.rb
|
184
184
|
- lib/acme/resources/authorization.rb
|
185
185
|
- lib/acme/resources/challenges.rb
|
186
|
-
- lib/acme/resources/challenges/
|
186
|
+
- lib/acme/resources/challenges/base.rb
|
187
|
+
- lib/acme/resources/challenges/http01.rb
|
187
188
|
- lib/acme/resources/registration.rb
|
188
189
|
- lib/acme/version.rb
|
189
190
|
homepage: http://github.com/unixcharles/acme-client
|
@@ -1,50 +0,0 @@
|
|
1
|
-
class Acme::Resources::Challenges::SimpleHttp
|
2
|
-
CONTENT_TYPE = 'application/jose+json'
|
3
|
-
|
4
|
-
attr_reader :status, :uri, :token, :error
|
5
|
-
attr_accessor :tls
|
6
|
-
|
7
|
-
def initialize(client, attributes)
|
8
|
-
@client = client
|
9
|
-
assign_attributes(attributes)
|
10
|
-
end
|
11
|
-
|
12
|
-
def content_type
|
13
|
-
CONTENT_TYPE
|
14
|
-
end
|
15
|
-
|
16
|
-
def file_content
|
17
|
-
message = { 'type' => 'simpleHttp', 'token' => token, 'tls' => tls }
|
18
|
-
crypto.generate_signed_jws(header: {}, payload: message)
|
19
|
-
end
|
20
|
-
|
21
|
-
def filename
|
22
|
-
".well-known/acme-challenge/#{token}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def request_verification
|
26
|
-
response = @client.connection.post(@uri, { resource: 'challenge', type: 'simpleHttp', tls: tls })
|
27
|
-
response.success?
|
28
|
-
end
|
29
|
-
|
30
|
-
def verify_status
|
31
|
-
response = @client.connection.get(@uri)
|
32
|
-
|
33
|
-
assign_attributes(response.body)
|
34
|
-
@error = response.body['error']
|
35
|
-
status
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def assign_attributes(attributes)
|
41
|
-
@status = attributes.fetch('status', 'pending')
|
42
|
-
@uri = attributes.fetch('uri')
|
43
|
-
@token = attributes.fetch('token')
|
44
|
-
@tls = attributes.fetch('tls')
|
45
|
-
end
|
46
|
-
|
47
|
-
def crypto
|
48
|
-
@crypto ||= Acme::Crypto.new(@client.private_key)
|
49
|
-
end
|
50
|
-
end
|