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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 196af8b57f3799c3cecda28a1e8b5765a9ef54ca
4
- data.tar.gz: 9e6207457d8147280e70c6693585e06a369e102c
3
+ metadata.gz: c74c209bb0253bc39a30cb8244b9eea840820374
4
+ data.tar.gz: a33eca2a55b21390fd2e46403ab726b8ea29f31e
5
5
  SHA512:
6
- metadata.gz: 0415387b7ac41ef527ec759a2180090266f65db09811d2a1aac63d444fe4c5f42324dbe6dbb8eae3c4f4ea02698dec899ec47875e06362269761d1ad667f96cb
7
- data.tar.gz: 65e6c9782789b7c9183c9cf28cf8c8e85e83c4c39c76dbba1e3edc856b836c9c5de219ccd03900e440b4a146ff41380c3ebee2bad62be500dbd4dd1a12bae3fb
6
+ metadata.gz: 843045d5ed08e5260bd85744696eef0894c4a770b3b080c81027ed453e43eb016a6fe6e3ca00c97b70efb7a1a9de79b64fac67ec4cb1e511116608be9e7bc0f1
7
+ data.tar.gz: 6fac592f36eaa5d16ffb8a99dbcc02e2872d428f92c694e5bf7fab8441fe557514affb195a261b6fb19c265fd809990c73a1204d2179598106e39b2732fe39ff
@@ -24,9 +24,14 @@ module SSLTool
24
24
  end
25
25
 
26
26
  def key(s)
27
- OpenSSL::PKey::RSA.new(s, '')
28
- rescue OpenSSL::PKey::RSAError => e
29
- raise KeyMalformedError, "Key appears to be malformed, or is passphrase-protected."
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)
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssltool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Chassot