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



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

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.



191
192
193
# File 'lib/fluent/plugin/in_ssl_check.rb', line 191

def cert
  @cert
end

#cert_chainObject

Returns the value of attribute cert_chain.



191
192
193
# File 'lib/fluent/plugin/in_ssl_check.rb', line 191

def cert_chain
  @cert_chain
end

#errorObject

Returns the value of attribute error.



191
192
193
# File 'lib/fluent/plugin/in_ssl_check.rb', line 191

def error
  @error
end

#hostObject

Returns the value of attribute host.



191
192
193
# File 'lib/fluent/plugin/in_ssl_check.rb', line 191

def host
  @host
end

#portObject

Returns the value of attribute port.



191
192
193
# File 'lib/fluent/plugin/in_ssl_check.rb', line 191

def port
  @port
end

#ssl_versionObject

Returns the value of attribute ssl_version.



191
192
193
# File 'lib/fluent/plugin/in_ssl_check.rb', line 191

def ssl_version
  @ssl_version
end

#timeObject (readonly)

Returns the value of attribute time.



190
191
192
# File 'lib/fluent/plugin/in_ssl_check.rb', line 190

def time
  @time
end

Instance Method Details

#error_classObject



228
229
230
231
232
# File 'lib/fluent/plugin/in_ssl_check.rb', line 228

def error_class
  return unless error

  error.class.to_s
end

#expire_in_daysObject



209
210
211
212
213
214
# File 'lib/fluent/plugin/in_ssl_check.rb', line 209

def expire_in_days
  return unless cert&.not_after

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

#not_afterObject



216
217
218
219
220
# File 'lib/fluent/plugin/in_ssl_check.rb', line 216

def not_after
  return unless cert

  cert.not_after.iso8601(3)
end

#statusObject



222
223
224
225
226
# File 'lib/fluent/plugin/in_ssl_check.rb', line 222

def status
  return KO if error

  OK
end

#subject_sObject

rubocop:enable Metrics/ParameterLists



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

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