Class: Fluent::Plugin::SslCheck::FileChecker
- Inherits:
-
Object
- Object
- Fluent::Plugin::SslCheck::FileChecker
- Includes:
- SslCommon
- Defined in:
- lib/fluent/plugin/ssl_check/file_checker.rb
Instance Attribute Summary collapse
-
#ca_file ⇒ Object
readonly
Returns the value of attribute ca_file.
-
#ca_path ⇒ Object
readonly
Returns the value of attribute ca_path.
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Instance Method Summary collapse
- #certificate ⇒ Object
- #filepath_absolute ⇒ Object
- #hostname ⇒ Object
-
#initialize(filepath, ca_path: nil, ca_file: nil) ⇒ FileChecker
constructor
A new instance of FileChecker.
- #ssl_info ⇒ Object
Methods included from SslCommon
Constructor Details
#initialize(filepath, ca_path: nil, ca_file: nil) ⇒ FileChecker
Returns a new instance of FileChecker.
16 17 18 19 20 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 16 def initialize(filepath, ca_path: nil, ca_file: nil) @filepath = filepath @ca_path = ca_path @ca_file = ca_file end |
Instance Attribute Details
#ca_file ⇒ Object (readonly)
Returns the value of attribute ca_file.
12 13 14 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 12 def ca_file @ca_file end |
#ca_path ⇒ Object (readonly)
Returns the value of attribute ca_path.
12 13 14 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 12 def ca_path @ca_path end |
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
12 13 14 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 12 def filepath @filepath end |
Instance Method Details
#certificate ⇒ Object
22 23 24 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 22 def certificate @certificate ||= OpenSSL::X509::Certificate.new(File.read(filepath_absolute)) end |
#filepath_absolute ⇒ Object
26 27 28 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 26 def filepath_absolute File.(filepath) end |
#hostname ⇒ Object
45 46 47 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 45 def hostname Socket.gethostname end |
#ssl_info ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/ssl_check/file_checker.rb', line 30 def ssl_info info = Fluent::Plugin::SslCheck::SslInfo.new(host: hostname, path: filepath_absolute) begin ca_store = ssl_store(ca_path: ca_path, ca_file: ca_file) ca_store.verify(certificate) info.cert = certificate info.cert_chain = ca_store.chain info.error = ca_store.error_string if ca_store.error != 0 rescue StandardError => e info.error = e end info end |