rails-letsencrypt 0.5.5 → 0.6.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5be585e8379ddfbc487d70af910c3cf3302fb69b
|
4
|
+
data.tar.gz: 492664cf69aaf349837c0ae4f776ebb5fd6d913f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02564ed000fac27c0c623da185ffb58d0e37665fc979bf565d7e69a64743b88990991fd82962cc97aa23fd0e18ad6ace0d527561bc9c2addaff3fc494dd61cc3
|
7
|
+
data.tar.gz: b90615e07e0d1eeea7cb9deccc5b71926bd195d56d4e25ec304d2ce2f9c04a181db28599acb8a4c7123313115087404943d9f621638cbcc09a104db34df9bfed
|
@@ -18,21 +18,22 @@ module LetsEncrypt
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def csr
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
Acme::Client::CertificateRequest.new(
|
22
|
+
private_key: OpenSSL::PKey::RSA.new(key),
|
23
|
+
subject: {
|
24
|
+
common_name: domain
|
25
|
+
}
|
24
26
|
)
|
25
|
-
private_key = OpenSSL::PKey::RSA.new(key)
|
26
|
-
csr.public_key = private_key.public_key
|
27
|
-
csr.sign(private_key, OpenSSL::Digest::SHA256.new)
|
28
|
-
csr
|
29
27
|
end
|
30
28
|
|
31
29
|
def create_certificate
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
order.finalize(csr: csr)
|
31
|
+
sleep 1 while order.status == 'processing'
|
32
|
+
fullchain = order.certificate.split("\n\n")
|
33
|
+
cert = OpenSSL::X509::Certificate.new(fullchain.shift)
|
34
|
+
self.certificate = cert.to_pem
|
35
|
+
self.intermediaries = fullchain.join("\n\n")
|
36
|
+
self.expires_at = cert.not_after
|
36
37
|
self.renew_after = (expires_at - 1.month) + rand(10).days
|
37
38
|
save!
|
38
39
|
end
|
@@ -7,7 +7,7 @@ module LetsEncrypt
|
|
7
7
|
|
8
8
|
# Returns true if verify domain is succeed.
|
9
9
|
def verify
|
10
|
-
|
10
|
+
create_order
|
11
11
|
start_challenge
|
12
12
|
wait_verify_status
|
13
13
|
check_verify_status
|
@@ -17,9 +17,9 @@ module LetsEncrypt
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def
|
21
|
-
|
22
|
-
@challenge =
|
20
|
+
def create_order
|
21
|
+
# TODO: Support multiple domain
|
22
|
+
@challenge = order.authorizations.first.http
|
23
23
|
self.verification_path = @challenge.filename
|
24
24
|
self.verification_string = @challenge.file_content
|
25
25
|
save!
|
@@ -27,24 +27,25 @@ module LetsEncrypt
|
|
27
27
|
|
28
28
|
def start_challenge
|
29
29
|
logger.info "Attempting verification of #{domain}"
|
30
|
-
@challenge.
|
30
|
+
@challenge.request_validation
|
31
31
|
end
|
32
32
|
|
33
33
|
def wait_verify_status
|
34
34
|
checks = 0
|
35
|
-
until @challenge.
|
35
|
+
until @challenge.status != 'pending'
|
36
36
|
checks += 1
|
37
37
|
if checks > 30
|
38
38
|
logger.info 'Status remained at pending for 30 checks'
|
39
39
|
return false
|
40
40
|
end
|
41
41
|
sleep 1
|
42
|
+
@challenge.reload
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
def check_verify_status
|
46
|
-
unless @challenge.
|
47
|
-
logger.info "Status was not valid (was: #{@challenge.
|
47
|
+
unless @challenge.status == 'valid'
|
48
|
+
logger.info "Status was not valid (was: #{@challenge.status})"
|
48
49
|
return false
|
49
50
|
end
|
50
51
|
|
data/lib/letsencrypt.rb
CHANGED
@@ -12,18 +12,18 @@ require 'letsencrypt/redis'
|
|
12
12
|
# :nodoc:
|
13
13
|
module LetsEncrypt
|
14
14
|
# Production mode API Endpoint
|
15
|
-
ENDPOINT = 'https://acme-
|
15
|
+
ENDPOINT = 'https://acme-v02.api.letsencrypt.org/directory'
|
16
16
|
|
17
17
|
# Staging mode API Endpoint, the rate limit is higher
|
18
18
|
# but got invalid certificate for testing
|
19
|
-
ENDPOINT_STAGING = 'https://acme-staging.api.letsencrypt.org'
|
19
|
+
ENDPOINT_STAGING = 'https://acme-staging-v02.api.letsencrypt.org/directory'
|
20
20
|
|
21
21
|
class << self
|
22
22
|
# Create the ACME Client to Let's Encrypt
|
23
23
|
def client
|
24
24
|
@client ||= ::Acme::Client.new(
|
25
25
|
private_key: private_key,
|
26
|
-
|
26
|
+
directory: directory
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
@@ -38,7 +38,7 @@ module LetsEncrypt
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Get current using Let's Encrypt endpoint
|
41
|
-
def
|
41
|
+
def directory
|
42
42
|
@endpoint ||= config.use_staging? ? ENDPOINT_STAGING : ENDPOINT
|
43
43
|
end
|
44
44
|
|
@@ -49,10 +49,9 @@ module LetsEncrypt
|
|
49
49
|
# connect with domain and assign the owner who can
|
50
50
|
# renew and revoked.
|
51
51
|
def register(email)
|
52
|
-
|
52
|
+
account = client.new_account(contact: "mailto:#{email}", terms_of_service_agreed: true)
|
53
53
|
logger.info "Successfully registered private key with address #{email}"
|
54
|
-
|
55
|
-
logger.info 'Terms have been accepted'
|
54
|
+
account.kid # TODO: Save KID
|
56
55
|
true
|
57
56
|
end
|
58
57
|
|
data/lib/letsencrypt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-letsencrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 蒼時弦也
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: redis
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|