ssltool 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ssltool/certificate.rb +16 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00acc97c34c1f47fcc5cbf00dba1e05ecddd5a85
4
- data.tar.gz: 60db4e3ed86c4565d1697843e8999f88fb47cd20
3
+ metadata.gz: 6fe5a7e781f83fb69dfd7ff57f6fafc215ca9276
4
+ data.tar.gz: e6d9ebcafbab556ecd142fd878056da8c7ebc0b4
5
5
  SHA512:
6
- metadata.gz: df65ca049c8d2c6c2189e2e4126ec23eae7c525b5831acd0ad5a4ba4bdeef48e115c4e8206ddeff452f1ba463984ca9f53d927dac0090319a8a0514be3ba46a9
7
- data.tar.gz: 27792d65f565ca941bb168eed1e8bd96000f5e1e5f3f6b79c0edde8a224dfc8f36b1387766680fbd383fc5c6f3c4b57e1a1469a6949f8f3a3b167e2c3ddccf24
6
+ metadata.gz: 670409887283d19c580840088dc852e794787341fa93f5196f9d845ff69fa5518b0b2fa1dc81c90e770f4f119001d6c1916dc77a30bc837c50d10edcb69fba8a
7
+ data.tar.gz: c8ca3931bd183f2132f1f1e7bdef8d291430429814e88710995f9bfd92c0849f4ebbdbe8e804ff3e506f5389a92c83356938261497e67310fcab689990a1833f
@@ -48,6 +48,12 @@ module SSLTool
48
48
  subject.eql?(issuer)
49
49
  end
50
50
 
51
+ def parent?(other_cert)
52
+ signs?(other_cert) \
53
+ && subject == other_cert.issuer \
54
+ && subject_key_identifier == other_cert.authority_key_identifier
55
+ end
56
+
51
57
  ### properties
52
58
 
53
59
  def fingerprint
@@ -84,6 +90,14 @@ module SSLTool
84
90
  map_extension_value('keyUsage') { |s| s.split(", ").include?('Certificate Sign') }
85
91
  end
86
92
 
93
+ def subject_key_identifier
94
+ map_extension_value('subjectKeyIdentifier') { |s| s.chomp }
95
+ end
96
+
97
+ def authority_key_identifier
98
+ map_extension_value('authorityKeyIdentifier') { |s| s.sub(/^keyid:/, '').chomp }
99
+ end
100
+
87
101
  def key_size
88
102
  case public_key
89
103
  when OpenSSL::PKey::RSA ; public_key.n.num_bits
@@ -125,14 +139,14 @@ module SSLTool
125
139
  def map_extension_value(extension_name, default = nil)
126
140
  e = extensions[extension_name]
127
141
  return default if e.nil?
128
- yield(e.value)
142
+ block_given? ? yield(e.value) : e.value
129
143
  end
130
144
 
131
145
  ### chain
132
146
 
133
147
  def chain_from(certs)
134
148
  chain = [self]
135
- parent = (certs - chain).find { |cert| cert.signs?(self) }
149
+ parent = (certs - chain).find { |cert| cert.parent?(self) }
136
150
  chain.concat(parent.chain_from(certs - chain)) if parent
137
151
  chain
138
152
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssltool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Chassot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Orders and completes SSL certificate trust chains, maintains an up-to-date
14
14
  pool of viable intermediates and trusted roots, and provides other tooling for dealing