def find_objects(template={})
      all_objs = [] unless block_given?
      C_FindObjectsInit(template)
      begin
        loop do
          objs = C_FindObjects(20)
          break if objs.empty?
          if block_given?
            objs.each{|obj| yield obj }
          else
            all_objs += objs
          end
        end
      ensure
        C_FindObjectsFinal()
      end
      return all_objs
    end
def find_objects(template={})
      all_objs = [] unless block_given?
      C_FindObjectsInit(template)
      begin
        loop do
          objs = C_FindObjects(20)
          break if objs.empty?
          if block_given?
            objs.each{|obj| yield obj }
          else
            all_objs += objs
          end
        end
      ensure
        C_FindObjectsFinal()
      end
      return all_objs
    end
Convenience method for the {Session#C_FindObjectsInit}, {Session#C_FindObjects}, {Session#C_FindObjectsFinal} cycle.

 * If called with block, it iterates over all found objects.
 * If called without block, it returns with an array of all found Object instances.
 @return [Array<PKCS11::Object>]

 @example prints subject of all certificates stored in the token:
   session.find_objects(:CLASS => PKCS11::CKO_CERTIFICATE) do |obj|
     p OpenSSL::X509::Name.new(obj[:SUBJECT])
   end