Browse Source

Include fingerprint certificate

new-scoring
aeris 2 years ago
parent
commit
8d3c33d516
2 changed files with 12 additions and 5 deletions
  1. 6
    5
      lib/cryptcheck/tls/cert.rb
  2. 6
    0
      lib/cryptcheck/tls/fixture.rb

+ 6
- 5
lib/cryptcheck/tls/cert.rb View File

@@ -88,7 +88,7 @@ module CryptCheck
88 88
 			end
89 89
 
90 90
 			def fingerprint
91
-				::OpenSSL::Digest::SHA256.hexdigest @cert.to_der
91
+				@cert.fingerprint
92 92
 			end
93 93
 
94 94
 			def key
@@ -120,10 +120,11 @@ module CryptCheck
120 120
 						fingerprint: self.fingerprint,
121 121
 						chain:       @chain.collect do |cert|
122 122
 							{
123
-									subject:  cert.subject.to_s,
124
-									serial:   cert.serial.to_s,
125
-									issuer:   cert.issuer.to_s,
126
-									lifetime: { not_before: cert.not_before, not_after: cert.not_after }
123
+									subject:     cert.subject.to_s,
124
+									serial:      cert.serial.to_s,
125
+									issuer:      cert.issuer.to_s,
126
+									fingerprint: cert.fingerprint,
127
+									lifetime:    { not_before: cert.not_before, not_after: cert.not_after }
127 128
 							}
128 129
 						end,
129 130
 						key:         self.key.to_h,

+ 6
- 0
lib/cryptcheck/tls/fixture.rb View File

@@ -150,6 +150,12 @@ class ::OpenSSL::PKey::DH
150 150
 	end
151 151
 end
152 152
 
153
+class ::OpenSSL::X509::Certificate
154
+	def fingerprint
155
+		::OpenSSL::Digest::SHA256.hexdigest self.to_der
156
+	end
157
+end
158
+
153 159
 class ::OpenSSL::X509::Store
154 160
 	def add_chains(chains)
155 161
 		chains = [chains] unless chains.is_a? Enumerable

Loading…
Cancel
Save