Skip to content

Commit

Permalink
ENH: imap collector: support unverified connections
Browse files Browse the repository at this point in the history
use existing standard http_verify_cert parameter to determine if
certificate should be checked or not.
default (backwards-compatible) is to verify the server certificate
  • Loading branch information
Sebastian Wagner authored and Wagner committed Aug 23, 2021
1 parent 9550f86 commit 34e83bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit 34e83bd

Please sign in to comment.