Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Pass ssl_verification value to the IMAP library

Fahad Alduraibi890125e0c962
diff --git a/lib/redmine/imap.rb b/lib/redmine/imap.rb
index 25e1249eff8..7b9aaace0d0 100644
--- a/lib/redmine/imap.rb
+++ b/lib/redmine/imap.rb
@@ -48,24 +48,15 @@ module Redmine
def connect_imap(imap_options)
host = imap_options[:host] || '127.0.0.1'
port = imap_options[:port] || '143'
- ssl = ssl_option(imap_options)
- imap = Net::IMAP.new(host, port, ssl)
+ ssl = imap_options[:ssl]
+ ssl_verification = imap_options[:ssl_verification]
+ imap = Net::IMAP.new(host, port, ssl, nil, ssl_verification)
imap.login(imap_options[:username], imap_options[:password]) unless imap_options[:username].nil?
imap
end
- def ssl_option(imap_options)
- return false if imap_options[:ssl] == false # don't use SSL
-
- if imap_options[:ssl_verification] == false
- { verify_mode: OpenSSL::SSL::VERIFY_NONE } # use SSL without verification
- else
- true # use SSL with verification
- end
- end
-
def receive(message_id, imap, imap_options, options)
msg = imap.fetch(message_id, 'RFC822')[0].attr['RFC822']
raise "Message was not successfully handled." unless MailHandler.receive(msg, options)