class Tinycert::Certs

Constants

EXPIRED
GOOD
HOLD
REVOKED

Attributes

ca[R]

Public Class Methods

new(tinycert, ca) click to toggle source
# File lib/tinycert/certs.rb, line 10
def initialize tinycert, ca
  @tinycert = tinycert
  @ca = ca
end

Public Instance Methods

[](cert_id) click to toggle source
# File lib/tinycert/certs.rb, line 36
def [](cert_id)
  request = @tinycert.session_request 'https://www.tinycert.org/api/v1/cert/details', { cert_id: cert_id, token: @tinycert.token }
  Tinycert::Cert.new @tinycert, results
end
create(name, c:'US', l:nil, o:nil, ou:nil, st: nil, names:[]) click to toggle source
# File lib/tinycert/certs.rb, line 41
def create name, c:'US', l:nil, o:nil, ou:nil, st: nil, names:[]
  # Include the common name in the SANs too
  all_names = names << name

  indexed_names = all_names.uniq.each_with_index.inject({}) { |all, (n, index)|
    all["SANs[#{index}][DNS]"] = n
    all
  }
  request_params = {
    CN: name,
    C: c,
    O: o,
    OU: ou,
    ST: st,
    ca_id: ca.id
   }.merge(indexed_names).reject { |k,v| v.nil? }
  request = @tinycert.session_request 'https://www.tinycert.org/api/v1/cert/new', request_params
  Tinycert::Cert.new @tinycert, request.results
end
expired() click to toggle source
# File lib/tinycert/certs.rb, line 15
def expired
  list EXPIRED
end
good() click to toggle source
# File lib/tinycert/certs.rb, line 19
def good
  list GOOD
end
hold() click to toggle source
# File lib/tinycert/certs.rb, line 27
def hold
  list HOLD
end
list(what) click to toggle source
# File lib/tinycert/certs.rb, line 31
def list what
  request = @tinycert.session_request 'https://www.tinycert.org/api/v1/cert/list', { ca_id: ca.id, what: what, token: @tinycert.token }
  request.results.collect { |c| Tinycert::Cert.new @tinycert, c }
end
revoked() click to toggle source
# File lib/tinycert/certs.rb, line 23
def revoked
  list REVOKED
end