Module: LetsEncrypt
- Defined in:
- lib/letsencrypt.rb,
lib/letsencrypt/redis.rb,
lib/letsencrypt/engine.rb,
lib/letsencrypt/railtie.rb,
lib/letsencrypt/version.rb,
lib/letsencrypt/logger_proxy.rb,
lib/letsencrypt/configuration.rb,
app/models/lets_encrypt/certificate.rb,
app/jobs/lets_encrypt/application_job.rb,
app/jobs/lets_encrypt/renew_certificates_job.rb,
lib/generators/lets_encrypt/install_generator.rb,
lib/generators/lets_encrypt/register_generator.rb,
app/controllers/lets_encrypt/application_controller.rb,
app/controllers/lets_encrypt/verifications_controller.rb,
app/models/concerns/lets_encrypt/certificate_issuable.rb,
app/models/concerns/lets_encrypt/certificate_verifiable.rb
Overview
Defined Under Namespace
Modules: CertificateIssuable, CertificateVerifiable, Generators
Classes: ApplicationController, ApplicationJob, Certificate, Configuration, Engine, LoggerProxy, Railtie, Redis, RenewCertificatesJob, VerificationsController
Constant Summary
collapse
- ENDPOINT =
'https://acme-v01.api.letsencrypt.org/'
- ENDPOINT_STAGING =
'https://acme-staging.api.letsencrypt.org'
- VERSION =
'0.5.0'
Class Method Summary
collapse
Class Method Details
.client ⇒ Object
18
19
20
21
22
23
|
# File 'lib/letsencrypt.rb', line 18
def client
@client ||= ::Acme::Client.new(
private_key: private_key,
endpoint: endpoint
)
end
|
.config(&block) ⇒ Object
62
63
64
65
66
|
# File 'lib/letsencrypt.rb', line 62
def config(&block)
@config ||= Configuration.new
instance_exec(@config, &block) if block_given?
@config
end
|
.endpoint ⇒ Object
35
36
37
|
# File 'lib/letsencrypt.rb', line 35
def endpoint
@endpoint ||= config.use_staging? ? ENDPOINT_STAGING : ENDPOINT
end
|
.generate_private_key ⇒ Object
51
52
53
54
55
56
|
# File 'lib/letsencrypt.rb', line 51
def generate_private_key
key = OpenSSL::PKey::RSA.new(4096)
File.open(private_key_path, 'w') { |f| f.write(key.to_s) }
logger.info "Created new private key for Let's Encrypt"
key
end
|
.load_private_key ⇒ Object
29
30
31
32
33
|
# File 'lib/letsencrypt.rb', line 29
def load_private_key
return ENV['LETSENCRYPT_PRIVATE_KEY'] if config.use_env_key
return File.open(private_key_path) if File.exist?(private_key_path)
generate_private_key
end
|
.logger ⇒ Object
58
59
60
|
# File 'lib/letsencrypt.rb', line 58
def logger
@logger ||= LoggerProxy.new(Rails.logger, tags: ['LetsEncrypt'])
end
|
.private_key ⇒ Object
25
26
27
|
# File 'lib/letsencrypt.rb', line 25
def private_key
@private_key ||= OpenSSL::PKey::RSA.new(load_private_key)
end
|
.private_key_path ⇒ Object
47
48
49
|
# File 'lib/letsencrypt.rb', line 47
def private_key_path
config.private_key_path || Rails.root.join('config', 'letsencrypt.key')
end
|
.register(email) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/letsencrypt.rb', line 39
def register(email)
registration = client.register(contact: "mailto:#{email}")
logger.info "Successfully registered private key with address #{email}"
registration.agree_terms
logger.info 'Terms have been accepted'
true
end
|
.table_name_prefix ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
69
70
71
|
# File 'lib/letsencrypt.rb', line 69
def table_name_prefix
'letsencrypt_'
end
|