101: def find_private_keys(path)
102: raise "#{path} does not exist" unless File.exists?(path || '')
103: if File.directory?(path)
104: files = Dir.entries(path).collect { |file| File.join(path, file) }
105: else
106: files = [path]
107: end
108:
109: files = files.select do |file|
110: next if File.directory?(file)
111: pk = nil
112: begin
113: tmp = Rye::Key.from_file(file)
114: pk = tmp if tmp.private?
115: rescue OpenSSL::PKey::PKeyError
116: end
117: !pk.nil?
118: end
119: files || []
120: end