Skip to content

Commit 34e83bd

Browse files
Sebastian WagnerWagner
authored andcommitted
ENH: imap collector: support unverified connections
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
1 parent 9550f86 commit 34e83bd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CHANGELOG
1919

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

2324
#### Parsers
2425

intelmq/bots/collectors/mail/_lib.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class MailCollectorBot(CollectorBot):
2929
sent_to = None
3030
sent_from = None
3131
subject_regex = None
32+
http_verify_cert: bool = True
3233

3334
def init(self):
3435
if imbox is None:
@@ -41,8 +42,11 @@ def init(self):
4142

4243
def connect_mailbox(self):
4344
self.logger.debug("Connecting to %s.", self.mail_host)
44-
ca_file = self.ssl_ca_certificate
45-
ssl_custom_context = ssl.create_default_context(cafile=ca_file)
45+
if self.http_verify_cert is True:
46+
ca_file = self.ssl_ca_certificate
47+
ssl_custom_context = ssl.create_default_context(cafile=ca_file)
48+
else:
49+
ssl_custom_context = ssl._create_unverified_context()
4650
mailbox = imbox.Imbox(self.mail_host,
4751
self.mail_user,
4852
self.mail_password,

0 commit comments

Comments
 (0)