# File lib/mcollective/security/aes_security.rb, line 180
      def encoderequest(sender, msg, requestid, filter, target_agent, target_collective, ttl=60)
        req = create_request(requestid, filter, nil, @initiated_by, target_agent, target_collective, ttl)

        # embed the ttl and msgtime in the crypted data later we will use these in
        # the decoding of a message to set the message ones from secure sources. this
        # is to ensure messages are not tampered with to facility replay attacks etc
        aes_msg = {:aes_msg => msg,
          :aes_ttl => ttl,
          :aes_msgtime => req[:msgtime]}

        crypted = encrypt(serialize(aes_msg), callerid)

        req[:body] = crypted[:data]
        req[:sslkey] = crypted[:key]

        if @config.pluginconf.include?("aes.send_pubkey") && @config.pluginconf["aes.send_pubkey"] == "1"
          if @initiated_by == :client
            req[:sslpubkey] = File.read(client_public_key)
          else
            req[:sslpubkey] = File.read(server_public_key)
          end
        end

        serialize(req)
      end