Class: Curl
- Inherits:
-
Object
- Object
- Curl
- Defined in:
- lib/curl.rb
Overview
TODO: rename of class (should show real function, not information that cert validation is done by output from curl)
Instance Attribute Summary collapse
-
#serverCertificate ⇒ Object
readonly
Returns the value of attribute serverCertificate.
Instance Method Summary collapse
- #getCertInfo(string) ⇒ Object
-
#initialize(string = '') ⇒ Curl
constructor
A new instance of Curl.
- #parse(string) ⇒ Object
Constructor Details
Instance Attribute Details
#serverCertificate ⇒ Object (readonly)
Returns the value of attribute serverCertificate.
5 6 7 |
# File 'lib/curl.rb', line 5 def serverCertificate @serverCertificate end |
Instance Method Details
#getCertInfo(string) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/curl.rb', line 32 def getCertInfo(string) regexp = %r{\*\sServer\scertificate:\s+ \s+\*\s+subject:\s+(CN=[\w\.]+,O=[\w\s]+,L=[\w\s]+,ST=\w+,C=\w{2})\s+ \s+\*\s+start\s+date:\s+(Jan 10 09:39:00 2018 GMT)\s+ \s+\*\s+expire\s+date:\s+(Apr 04 09:39:00 2018 GMT)\s+ \s+\*\s+common\s+name:\s+(\w+)\s+ \s+\*\s+issuer:\s+(CN=[\w\.]+,C=\w{2})\s+}x match = regexp.match(string) if match @serverCertificate['subject'] = match[1] @serverCertificate['start date'] = match[2] @serverCertificate['expire date'] = match[3] @serverCertificate['common name'] = match[4] @serverCertificate['issuer'] = match[5] else puts string puts regexp puts match puts "regexp couldn't decode string #{string}" raise end end |
#parse(string) ⇒ Object
18 19 20 21 |
# File 'lib/curl.rb', line 18 def parse(string) self.getCertInfo(string) end |