From 527d1f756ab57cb5b1449893dbff5ab1ead861fc Mon Sep 17 00:00:00 2001 From: Lucas Nussbaum Date: Sun, 18 Apr 2010 14:25:14 +0200 Subject: provide a way to disable SSL certificate verification --- ChangeLog | 2 ++ data/doc/feed2imap/examples/feed2imaprc | 2 ++ lib/feed2imap/config.rb | 1 + lib/feed2imap/imap.rb | 8 +++++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 89696c5..dc9bf41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ Feed2Imap 0.9.5 (XX/XX/2010)? * Use Message-ID instead of X-CacheIndex * Do not use acme.com * Update rubyimap.rb +* Provide a way to disable SSL certification verification when + connecting to IMAPS accounts Feed2Imap 0.9.4 (27/07/2009) ============================ diff --git a/data/doc/feed2imap/examples/feed2imaprc b/data/doc/feed2imap/examples/feed2imaprc index 99aab33..4fd8797 100644 --- a/data/doc/feed2imap/examples/feed2imaprc +++ b/data/doc/feed2imap/examples/feed2imaprc @@ -8,6 +8,8 @@ # about the "updated-items" algorithm. # include-images: download images and include them in the mail? (true/false) # default-email: default email address in the format foo@example.com +# disable-ssl-verification: disable SSL certification when connecting +# to IMAPS accounts (true/false) # # Per-feed options: # name: name of the feed (must be unique) diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb index a9c796c..53e6543 100644 --- a/lib/feed2imap/config.rb +++ b/lib/feed2imap/config.rb @@ -47,6 +47,7 @@ class F2IConfig @updateddebug = (@conf['debug-updated'] and @conf['debug-updated'] != 'false') @include_images = (@conf['include-images'] and @conf['include-images'] != 'false') @default_email = (@conf['default-email'] || "#{LOGNAME}@#{HOSTNAME}") + ImapAccount.no_ssl_verify = (@conf['disable-ssl-verification'] and @conf['disable-ssl-verification'] != 'false') @hostname = HOSTNAME # FIXME: should this be configurable as well? @imap_accounts = ImapAccounts::new maildir_account = MaildirAccount::new diff --git a/lib/feed2imap/imap.rb b/lib/feed2imap/imap.rb index 6840c11..c4e7106 100644 --- a/lib/feed2imap/imap.rb +++ b/lib/feed2imap/imap.rb @@ -30,6 +30,7 @@ require 'uri' # using the same IMAP account will create only one # IMAP connection. class ImapAccounts < Hash + def add_account(uri) u = URI::Generic::build({ :scheme => uri.scheme, :userinfo => uri.userinfo, @@ -48,6 +49,11 @@ end class ImapAccount attr_reader :uri + @@no_ssl_verify = false + def ImapAccount::no_ssl_verify=(v) + @@no_ssl_verify = v + end + def initialize(uri) @uri = uri @existing_folders = [] @@ -70,7 +76,7 @@ class ImapAccount end # use given port if port given port = uri.port if uri.port - @connection = Net::IMAP::new(uri.host, port, usessl) + @connection = Net::IMAP::new(uri.host, port, usessl, nil, !@@no_ssl_verify) user, password = URI::unescape(uri.userinfo).split(':',2) @connection.login(user, password) self -- cgit v1.2.3