Class: Tinycert::Certs
- Inherits:
-
Object
- Object
- Tinycert::Certs
- Defined in:
- lib/tinycert/certs.rb
Constant Summary collapse
- EXPIRED =
1
- GOOD =
2
- REVOKED =
4
- HOLD =
8
Instance Attribute Summary collapse
-
#ca ⇒ Object
readonly
Returns the value of attribute ca.
Instance Method Summary collapse
- #[](cert_id) ⇒ Object
- #create(name, c: 'US', l: nil, o: nil, ou: nil, st: nil, names: []) ⇒ Object
- #expired ⇒ Object
- #good ⇒ Object
- #hold ⇒ Object
-
#initialize(tinycert, ca) ⇒ Certs
constructor
A new instance of Certs.
- #list(what) ⇒ Object
- #revoked ⇒ Object
Constructor Details
#initialize(tinycert, ca) ⇒ Certs
Returns a new instance of Certs.
10 11 12 13 |
# File 'lib/tinycert/certs.rb', line 10 def initialize tinycert, ca @tinycert = tinycert @ca = ca end |
Instance Attribute Details
#ca ⇒ Object (readonly)
Returns the value of attribute ca.
3 4 5 |
# File 'lib/tinycert/certs.rb', line 3 def ca @ca end |
Instance Method Details
#[](cert_id) ⇒ Object
36 37 38 39 |
# 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: []) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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 ⇒ Object
15 16 17 |
# File 'lib/tinycert/certs.rb', line 15 def expired list EXPIRED end |
#good ⇒ Object
19 20 21 |
# File 'lib/tinycert/certs.rb', line 19 def good list GOOD end |
#hold ⇒ Object
27 28 29 |
# File 'lib/tinycert/certs.rb', line 27 def hold list HOLD end |
#list(what) ⇒ Object
31 32 33 34 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/tinycert/certs.rb', line 23 def revoked list REVOKED end |