Class: Fluent::Plugin::SslCheckInput::SslInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/in_ssl_check.rb

Overview

ssl info

to encapsulate extracted ssl information

Constant Summary collapse

OK =
1
KO =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host: nil, port: nil, cert: nil, cert_chain: nil, ssl_version: nil, error: nil, time: Time.now) ⇒ SslInfo

rubocop:disable Metrics/ParameterLists



170
171
172
173
174
175
176
177
178
# File 'lib/fluent/plugin/in_ssl_check.rb', line 170

def initialize(host: nil, port: nil, cert: nil, cert_chain: nil, ssl_version: nil, error: nil, time: Time.now)
  @host = host
  @port = port
  @cert = cert
  @cert_chain = cert_chain
  @ssl_version = ssl_version
  @error = error
  @time = time
end

Instance Attribute Details

#certObject

Returns the value of attribute cert.



167
168
169
# File 'lib/fluent/plugin/in_ssl_check.rb', line 167

def cert
  @cert
end

#cert_chainObject

Returns the value of attribute cert_chain.



167
168
169
# File 'lib/fluent/plugin/in_ssl_check.rb', line 167

def cert_chain
  @cert_chain
end

#errorObject

Returns the value of attribute error.



167
168
169
# File 'lib/fluent/plugin/in_ssl_check.rb', line 167

def error
  @error
end

#hostObject

Returns the value of attribute host.



167
168
169
# File 'lib/fluent/plugin/in_ssl_check.rb', line 167

def host
  @host
end

#portObject

Returns the value of attribute port.



167
168
169
# File 'lib/fluent/plugin/in_ssl_check.rb', line 167

def port
  @port
end

#ssl_versionObject

Returns the value of attribute ssl_version.



167
168
169
# File 'lib/fluent/plugin/in_ssl_check.rb', line 167

def ssl_version
  @ssl_version
end

#timeObject (readonly)

Returns the value of attribute time.



166
167
168
# File 'lib/fluent/plugin/in_ssl_check.rb', line 166

def time
  @time
end

Instance Method Details

#error_classObject



204
205
206
207
208
# File 'lib/fluent/plugin/in_ssl_check.rb', line 204

def error_class
  return unless error

  error.class.to_s
end

#expire_in_daysObject



185
186
187
188
189
190
# File 'lib/fluent/plugin/in_ssl_check.rb', line 185

def expire_in_days
  return unless cert&.not_after

  expire_in = cert.not_after
  ((expire_in - time) / 3600 / 24).to_i
end

#not_afterObject



192
193
194
195
196
# File 'lib/fluent/plugin/in_ssl_check.rb', line 192

def not_after
  return unless cert

  cert.not_after.iso8601(3)
end

#statusObject



198
199
200
201
202
# File 'lib/fluent/plugin/in_ssl_check.rb', line 198

def status
  return KO if error

  OK
end

#subject_sObject

rubocop:enable Metrics/ParameterLists



181
182
183
# File 'lib/fluent/plugin/in_ssl_check.rb', line 181

def subject_s
  cert.subject.to_s if cert&.subject
end