jks 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/jks.rb +37 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9347420914fb8e0457b3503b7094b7b425cb74ce
|
4
|
+
data.tar.gz: 1c82d60cc74eab5f83c8e9a7041b5744ea69d580
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae7223cb0ac64c70672350647c0fbc70a1c697b5f60c4afd0aa43b7ecb733d9127f9eb53cfa6868a3f0acf3036bfe274d3fbf1b6481b2787621384c64115834e
|
7
|
+
data.tar.gz: 1c20287edc174c1b678205d106d7b4402dfcae159a820e85dc5ec00988ca247209d846421e34429b688955f8cac49e1f28c4882c81138b94214e9883664f1046
|
data/lib/jks.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
module OpenSSL
|
4
|
+
module X509
|
5
|
+
class Certificate
|
6
|
+
def days_left
|
7
|
+
(self.not_after - Time.now).to_i / (24 * 60 * 60)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class JKS
|
14
|
+
|
15
|
+
attr_accessor :keytool, :storepass
|
16
|
+
attr_reader :certs
|
17
|
+
|
18
|
+
def initialize(filename, storepass, keytool = nil, process = true)
|
19
|
+
@keytool = keytool ? keytool : 'keytool'
|
20
|
+
@filename = filename
|
21
|
+
@storepass = storepass
|
22
|
+
@certs = []
|
23
|
+
self.process if process
|
24
|
+
end
|
25
|
+
|
26
|
+
def process
|
27
|
+
keytoolcmd = "#{@keytool} -keystore #{@filename} -storepass #{@storepass} -list -rfc"
|
28
|
+
filtercmd = "awk '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/'"
|
29
|
+
result = `#{keytoolcmd} | #{filtercmd}`
|
30
|
+
result.scan(/(?=-----BEGIN CERTIFICATE-----)(.*?)(?<=-----END CERTIFICATE-----)/m).each do |pem|
|
31
|
+
p pem
|
32
|
+
cert = OpenSSL::X509::Certificate.new(pem.first)
|
33
|
+
@certs << cert
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zan Loy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: zan.loy@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/jks.rb
|
20
|
+
homepage: http://zanloy.com/ruby/jks/
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.5
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: A simple wrapper for keytool to read JKS files in ruby.
|
44
|
+
test_files: []
|