ssltool 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ This readme is very outdated and incomplete now. Enjoy :P
2
+
1
3
  # ssltool-complete-chain
2
4
 
3
5
  Re-orders and completes a chain for a given certificate.
@@ -6,7 +6,9 @@ require_relative "../lib/ssltool/certificate_store"
6
6
 
7
7
  (puts DATA.read.gsub("$0", File.basename($0)); exit 1) if ARGV.empty? && STDIN.tty?
8
8
 
9
- def notify_circular_chains_detected(circular_chains)
9
+ store = SSLTool::CertificateStore.new("file://#{File.dirname(__FILE__)}/../var/pools")
10
+
11
+ store.on_circular_chain_detection do |circular_chains|
10
12
  $stderr.puts "The following circular chains were detected:"
11
13
  $stderr.puts
12
14
  $stderr.puts "Resolve this manually and exclude the necessary certs to break the cycle by putting them your exclude pool; rerun this script."
@@ -30,10 +32,7 @@ def notify_circular_chains_detected(circular_chains)
30
32
  $stderr.puts cert.to_s
31
33
  end
32
34
  end
33
- public :notify_circular_chains_detected
34
35
 
35
- store = SSLTool::CertificateStore.new("file://#{File.dirname(__FILE__)}/../var/pools")
36
- store.register_for_circular_chain_detection_notification(self)
37
36
  store.detect_and_merge_intermediates!(SSLTool::Certificate.scan(ARGF.read), false)
38
37
 
39
38
  __END__
@@ -12,7 +12,7 @@ module SSLTool
12
12
  end
13
13
 
14
14
  def initialize(store_url)
15
- @circular_chain_notification_listeners = Set[]
15
+ @circular_chain_notification_callbacks = Set[]
16
16
  @adapter = create_adapter(store_url)
17
17
  @trusted_pool = @adapter.load_pool(:trusted)
18
18
  @intermediate_pool = @adapter.load_pool(:intermediate)
@@ -65,15 +65,13 @@ module SSLTool
65
65
  .each { |chain| chain.shift until chain[1..-1].to_a.any? { |other_cert| chain.first.signs?(other_cert) } || chain.empty? }
66
66
  .reject { |chain| chain.length <= 1 }
67
67
  .map(&:to_set).uniq.map(&:to_a)
68
- @circular_chain_notification_listeners.each { |listener| listener.notify_circular_chains_detected(circular_chains) } unless circular_chains.empty?
68
+ @circular_chain_notification_callbacks.each { |proc| proc.call(circular_chains) } unless circular_chains.empty?
69
69
  circular_chains
70
70
  end
71
71
 
72
- def register_for_circular_chain_detection_notification(listener = nil, &listener_block)
73
- listener && listener_block and raise ArgumentError, "Either pass a listener object or a block, never both."
74
- listener.nil? && listener_block.nil? and raise ArgumentError, "A listener object or a block is required."
75
- listener.nil? || listener.respond_to?(:notify_circular_chains_detected) or raise NoMethodError, "Listener does not define notify_circular_chains_detected(…)"
76
- @circular_chain_notification_listeners << listener || listener_block
72
+ def on_circular_chain_detection(&block)
73
+ raise ArgumentError, "Missing block" unless block_given?
74
+ @circular_chain_notification_callbacks << block
77
75
  end
78
76
 
79
77
  ### chains
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.8
4
+ version: 0.0.9
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-14 00:00:00.000000000 Z
12
+ date: 2012-09-20 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