Class: X509Sleuth::ScannerDetailedPresenter
- Inherits:
-
ScannerPresenter
- Object
- ScannerPresenter
- X509Sleuth::ScannerDetailedPresenter
- Defined in:
- lib/x509_sleuth/scanner_detailed_presenter.rb
Instance Attribute Summary
Attributes inherited from ScannerPresenter
Instance Method Summary collapse
Methods inherited from ScannerPresenter
Constructor Details
This class inherits a constructor from X509Sleuth::ScannerPresenter
Instance Method Details
#parse_cn(cert) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/x509_sleuth/scanner_detailed_presenter.rb', line 50 def parse_cn(cert) subject_parts = cert.subject.to_s.split("/").collect{ |p| p.split("=") } common_name = "" subject_parts.each do |part| if part[0] && part[0] == "CN" common_name = part[1] break end end common_name end |
#parse_san(cert) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/x509_sleuth/scanner_detailed_presenter.rb', line 62 def parse_san(cert) subject_alt_names = [] cert.extensions.each do |extension| if extension.oid == "subjectAltName" subject_alt_names = extension.value.split(/[:,]|\s/).reject{ |part| part.nil? || part.empty? || part == "DNS" } end end subject_alt_names end |
#tableize(clients) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/x509_sleuth/scanner_detailed_presenter.rb', line 6 def tableize(clients) clients.collect do |client| if client.peer_certificate { host: client.host, subject: client.peer_certificate.subject, common_name: parse_cn(client.peer_certificate), alt_names: parse_san(client.peer_certificate).join(","), issuer: client.peer_certificate.issuer, serial: client.peer_certificate.serial, not_before: client.peer_certificate.not_before, not_after: client.peer_certificate.not_after } else { host: client.host, subject: "", common_name: "", alt_names: [], issuer: "", serial: "", not_before: "", not_after: "" } end end end |
#to_s ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/x509_sleuth/scanner_detailed_presenter.rb', line 34 def to_s Formatador.display_compact_table( tableize(filter), [ :host, :subject, :common_name, :alt_names, :issuer, :serial, :not_before, :not_after ] ) end |