ssltool 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ module SSLTool
12
12
  end
13
13
 
14
14
  def initialize(store_url)
15
- @circular_chain_notification_callbacks = Set[]
15
+ @circular_chain_notification_callbacks = []
16
16
  @adapter = create_adapter(store_url)
17
17
  @trusted_pool = @adapter.load_pool(:trusted)
18
18
  @intermediate_pool = @adapter.load_pool(:intermediate)
@@ -5,6 +5,8 @@ require_relative 'pem_scanner'
5
5
  module SSLTool
6
6
  module KeyHelper
7
7
 
8
+ class KeyMalformedError < ArgumentError; end
9
+
8
10
  class KeyNotPresentError < ArgumentError; end
9
11
 
10
12
  class KeyNotFoundError < StandardError
@@ -21,8 +23,14 @@ module SSLTool
21
23
  PEMScanner.keys_from(s)
22
24
  end
23
25
 
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."
30
+ end
31
+
24
32
  def keys(*pems)
25
- pems.flatten.map { |s| OpenSSL::PKey::RSA.new(s, '') }
33
+ pems.flatten.map { |s| key(s) }
26
34
  end
27
35
 
28
36
  def find_private_key_for_certificate(cert, keys)
@@ -1,5 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  require_relative 'certificate'
3
+ require_relative 'key_helper'
3
4
 
4
5
  module SSLTool
5
6
  class PEMScanner
@@ -37,7 +38,7 @@ module SSLTool
37
38
  alias_method :certs, :certificates
38
39
 
39
40
  def keys
40
- key_strings.map { |s| OpenSSL::PKey::RSA.new(s, '') }
41
+ KeyHelper.keys(*key_strings)
41
42
  end
42
43
 
43
44
  end
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.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-20 00:00:00.000000000 Z
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Orders and completes SSL certificate trust chains, maintains an up-to-date
15
15
  pool of viable intermediates and trusted roots, and provides other tooling for dealing