Module: Model::AcmeAccount
- Extended by:
- ActiveSupport::Concern
- Included in:
- Com::AcmeAccount
- Defined in:
- app/models/com/model/acme_account.rb
Instance Method Summary collapse
- #account ⇒ Object
- #client ⇒ Object
- #contact ⇒ Object
- #directory ⇒ Object
- #generate_account ⇒ Object
- #private_key ⇒ Object
- #store_private_pem ⇒ Object
Instance Method Details
#account ⇒ Object
64 65 66 67 |
# File 'app/models/com/model/acme_account.rb', line 64 def account return @account if defined? @account @account = client.new_account(contact: contact, terms_of_service_agreed: true) end |
#client ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/models/com/model/acme_account.rb', line 46 def client return @client if defined? @client if self.kid @client = Acme::Client.new(private_key: private_key, directory: directory, kid: kid) else @client = Acme::Client.new(private_key: private_key, directory: directory) end end |
#contact ⇒ Object
60 61 62 |
# File 'app/models/com/model/acme_account.rb', line 60 def contact "mailto:#{email}" end |
#directory ⇒ Object
56 57 58 |
# File 'app/models/com/model/acme_account.rb', line 56 def directory RailsCom.config.acme_url end |
#generate_account ⇒ Object
32 33 34 35 |
# File 'app/models/com/model/acme_account.rb', line 32 def generate_account store_private_pem unless private_pem_blob self.update(kid: account.kid) end |
#private_key ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/models/com/model/acme_account.rb', line 23 def private_key return @private_key if defined? @private_key if private_pem_blob @private_key = OpenSSL::PKey::RSA.new(private_pem_blob.download) else @private_key = OpenSSL::PKey::RSA.new(4096) end end |
#store_private_pem ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/models/com/model/acme_account.rb', line 37 def store_private_pem Tempfile.open do |file| file.binmode file.write private_key.to_pem file.rewind self.private_pem.attach io: file, filename: "#{email}.pem" end end |