Sha256: 177e7086f06b8caae8dc6c1ea8f10f81231c1c38973a698166c5667d950c9c54

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

##
# This file is part of WhatWeb and may be subject to
# redistribution and commercial restrictions. Please see the WhatWeb
# web site for more information on licensing and terms of use.
# http://www.morningstarsecurity.com/research/whatweb
##
# Version 0.2 #
# Added content-type match
##
WhatWeb::Plugin.define "SSL-Certificate" do
  @author = "Brendan Coles <bcoles@gmail.com>" # 2010-10-29
  @version = "0.2"
  @description = "This plugin retrieves details from SSL certificate files."

  # 193 results for "-----BEGIN CERTIFICATE-----" "Signature Algorithm"  "-----END CERTIFICATE-----" ext:pem
  # 6 results for "-----BEGIN CERTIFICATE-----" "Signature Algorithm"  "-----END CERTIFICATE-----" ext:der

  def passive(target)
    m = []

    # Extract certificate details
    if target.body =~ /^-----BEGIN CERTIFICATE-----/ && target.body =~ /^-----END CERTIFICATE-----/ && target.body =~ /Public Key Algorithm:/ && target.body =~ /Signature Algorithm:/ && target.body =~ /Issuer:/

      m << { name: "SSL Cert Text" }
      m << { string: target.body.scan(/Issuer:[\s]*([^\r^\n]+)/)[0].to_s + " (" + target.body.scan(/RSA Public Key:[\s]*\(([^\)]+)\)/).flatten.first + ") (" + target.body.scan(/^[\s]+Not After : ([^\r^\n]+)/).flatten.first + ")" } if target.body =~ /Issuer:[\s]*([^\r^\n]+)/ && target.body =~ /RSA Public Key:[\s]*\(([^\)]+)\)/ && target.body =~ /^[\s]+Not After : ([^\r^\n]+)/

    end

    # Content type
    m << { string: "x-x509-ca-cert" } if target.headers["Content-Type"] =~ /^[\s]*application\/x-x509-ca-cert/

    m
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
simple_whatweb-0.4.1 lib/whatweb/plugins/ssl.rb
simple_whatweb-0.4.0 lib/whatweb/plugins/ssl.rb
simple_whatweb-0.3.0 lib/whatweb/plugins/ssl.rb
simple_whatweb-0.2.1 lib/whatweb/plugins/ssl.rb
simple_whatweb-0.2.0 lib/whatweb/plugins/ssl.rb
simple_whatweb-0.1.0 lib/whatweb/plugins/ssl.rb