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



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

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.



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

def cert
  @cert
end

#cert_chainObject

Returns the value of attribute cert_chain.



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

def cert_chain
  @cert_chain
end

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#portObject

Returns the value of attribute port.



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

def port
  @port
end

#ssl_versionObject

Returns the value of attribute ssl_version.



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

def ssl_version
  @ssl_version
end

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#error_classObject



235
236
237
238
239
# File 'lib/fluent/plugin/in_ssl_check.rb', line 235

def error_class
  return unless error

  error.class.to_s
end

#expire_in_daysObject



212
213
214
215
216
217
# File 'lib/fluent/plugin/in_ssl_check.rb', line 212

def expire_in_days
  return unless cert&.not_after

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

#not_afterObject



219
220
221
222
223
# File 'lib/fluent/plugin/in_ssl_check.rb', line 219

def not_after
  return unless cert

  cert.not_after.iso8601(3)
end

#serialObject



225
226
227
# File 'lib/fluent/plugin/in_ssl_check.rb', line 225

def serial
  cert&.serial&.to_s(16)&.downcase
end

#statusObject



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

def status
  return KO if error

  OK
end

#subject_sObject

rubocop:enable Metrics/ParameterLists



208
209
210
# File 'lib/fluent/plugin/in_ssl_check.rb', line 208

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