Class: Eld::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/eld/certificate.rb

Constant Summary collapse

GOOGLE_CERTIFICATES_URL =
"https://www.googleapis.com/robot/v1/metadata/x509/[email protected]"

Class Method Summary collapse

Class Method Details

.allObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/eld/certificate.rb', line 8

def self.all
  Eld.cache.fetch do
    response = HTTParty.get(GOOGLE_CERTIFICATES_URL)

    {
      expires_at: Time.parse(response.headers["expires"]).utc.to_i,
      data: JSON.parse(response.body)
    }
  end
end

.find(kid) ⇒ Object



19
20
21
22
23
# File 'lib/eld/certificate.rb', line 19

def self.find(kid)
  certificate = all[kid]

  OpenSSL::X509::Certificate.new(certificate)
end

.refreshObject



25
26
27
28
# File 'lib/eld/certificate.rb', line 25

def self.refresh
  Eld.cache.clear
  all
end