Skip to content

Commit

Permalink
Merge pull request elastic#1092 from subsection/master
Browse files Browse the repository at this point in the history
Added option to disable certificate validation in the IMAP input
  • Loading branch information
jordansissel committed Apr 22, 2014
2 parents fed2898 + 068078f commit cf32483
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/logstash/inputs/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class LogStash::Inputs::IMAP < LogStash::Inputs::Base
config :user, :validate => :string, :required => true
config :password, :validate => :password, :required => true
config :secure, :validate => :boolean, :default => true
config :verify_cert, :validate => :boolean, :default => true

config :fetch_count, :validate => :number, :default => 50
config :lowercase_headers, :validate => :boolean, :default => true
Expand All @@ -36,6 +37,10 @@ def register
require "net/imap" # in stdlib
require "mail" # gem 'mail'

if @secure and not @verify_cert
@logger.warn("Running IMAP without verifying the certificate may grant attackers unauthorized access to your mailbox or data")
end

if @port.nil?
if @secure
@port = 993
Expand All @@ -48,7 +53,11 @@ def register
end # def register

def connect
imap = Net::IMAP.new(@host, :port => @port, :ssl => @secure)
sslopt = @secure
if @secure and not @verify_cert
sslopt = { :verify_mode => OpenSSL::SSL::VERIFY_NONE }
end
imap = Net::IMAP.new(@host, :port => @port, :ssl => sslopt)
imap.login(@user, @password.value)
return imap
end
Expand Down

0 comments on commit cf32483

Please sign in to comment.