Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: imap collector: support unverified connections #2055

Merged
1 commit merged into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CHANGELOG

### Bots
#### Collectors
- `intelmq.bots.collectors.mail._lib`: Add support for unverified SSL/STARTTLS connections (PR#2055 by Sebastian Wagner).

#### Parsers

Expand Down
8 changes: 6 additions & 2 deletions intelmq/bots/collectors/mail/_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MailCollectorBot(CollectorBot):
sent_to = None
sent_from = None
subject_regex = None
http_verify_cert: bool = True

def init(self):
if imbox is None:
Expand All @@ -41,8 +42,11 @@ def init(self):

def connect_mailbox(self):
self.logger.debug("Connecting to %s.", self.mail_host)
ca_file = self.ssl_ca_certificate
ssl_custom_context = ssl.create_default_context(cafile=ca_file)
if self.http_verify_cert is True:
ca_file = self.ssl_ca_certificate
ssl_custom_context = ssl.create_default_context(cafile=ca_file)
else:
ssl_custom_context = ssl._create_unverified_context()
mailbox = imbox.Imbox(self.mail_host,
self.mail_user,
self.mail_password,
Expand Down