Class: JKS
- Inherits:
-
Object
- Object
- JKS
- Defined in:
- lib/jks.rb
Instance Attribute Summary collapse
-
#certs ⇒ Object
readonly
Returns the value of attribute certs.
-
#keytool ⇒ Object
Returns the value of attribute keytool.
-
#storepass ⇒ Object
Returns the value of attribute storepass.
Instance Method Summary collapse
-
#initialize(filename, storepass, keytool = nil, process = true) ⇒ JKS
constructor
A new instance of JKS.
- #process ⇒ Object
Constructor Details
#initialize(filename, storepass, keytool = nil, process = true) ⇒ JKS
Returns a new instance of JKS.
18 19 20 21 22 23 24 |
# File 'lib/jks.rb', line 18 def initialize(filename, storepass, keytool = nil, process = true) @keytool = keytool ? keytool : 'keytool' @filename = filename @storepass = storepass @certs = [] self.process if process end |
Instance Attribute Details
#certs ⇒ Object (readonly)
Returns the value of attribute certs.
16 17 18 |
# File 'lib/jks.rb', line 16 def certs @certs end |
#keytool ⇒ Object
Returns the value of attribute keytool.
15 16 17 |
# File 'lib/jks.rb', line 15 def keytool @keytool end |
#storepass ⇒ Object
Returns the value of attribute storepass.
15 16 17 |
# File 'lib/jks.rb', line 15 def storepass @storepass end |
Instance Method Details
#process ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jks.rb', line 26 def process keytoolcmd = "#{@keytool} -keystore #{@filename} -storepass #{@storepass} -list -rfc" filtercmd = "awk '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/'" result = `#{keytoolcmd} | #{filtercmd}` result.scan(/(?=-----BEGIN CERTIFICATE-----)(.*?)(?<=-----END CERTIFICATE-----)/m).each do |pem| p pem cert = OpenSSL::X509::Certificate.new(pem.first) @certs << cert end end |