ssltool 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ssltool/key_helper.rb +8 -3
- data/lib/ssltool/pem_scanner.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c74c209bb0253bc39a30cb8244b9eea840820374
|
4
|
+
data.tar.gz: a33eca2a55b21390fd2e46403ab726b8ea29f31e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 843045d5ed08e5260bd85744696eef0894c4a770b3b080c81027ed453e43eb016a6fe6e3ca00c97b70efb7a1a9de79b64fac67ec4cb1e511116608be9e7bc0f1
|
7
|
+
data.tar.gz: 6fac592f36eaa5d16ffb8a99dbcc02e2872d428f92c694e5bf7fab8441fe557514affb195a261b6fb19c265fd809990c73a1204d2179598106e39b2732fe39ff
|
data/lib/ssltool/key_helper.rb
CHANGED
@@ -24,9 +24,14 @@ module SSLTool
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def key(s)
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
error = -> { raise KeyMalformedError, "Key appears to be malformed, or is passphrase-protected." }
|
28
|
+
case s
|
29
|
+
when /\A-----BEGIN EC PRIVATE KEY/ then OpenSSL::PKey::EC.new(s, '')
|
30
|
+
when /\A-----BEGIN (RSA )?PRIVATE KEY/ then OpenSSL::PKey::RSA.new(s, '')
|
31
|
+
else error[]
|
32
|
+
end
|
33
|
+
rescue OpenSSL::PKey::ECError, OpenSSL::PKey::RSAError => e
|
34
|
+
error[]
|
30
35
|
end
|
31
36
|
|
32
37
|
def keys(*pems)
|
data/lib/ssltool/pem_scanner.rb
CHANGED
@@ -30,7 +30,7 @@ module SSLTool
|
|
30
30
|
s = s.dup.force_encoding('BINARY').gsub(/\r\n?/, "\n").gsub(/\s+\n/, "\n")
|
31
31
|
@pem_strings, @garbage_strings = s.split(RX_PEM_BLOCK).map(&:strip).reject(&:empty?).partition { |s| s =~ RX_PEM_BLOCK }
|
32
32
|
@cert_strings = @pem_strings.select { |s| s =~ /-----BEGIN CERTIFICATE-----/ }
|
33
|
-
@key_strings = @pem_strings.select { |s| s =~ /-----BEGIN (RSA )?PRIVATE KEY-----/ }
|
33
|
+
@key_strings = @pem_strings.select { |s| s =~ /-----BEGIN (EC |RSA )?PRIVATE KEY-----/ }
|
34
34
|
@garbage_strings += @pem_strings - @cert_strings - @key_strings
|
35
35
|
end
|
36
36
|
|