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

Enable working TLS to smtp.office365.com #166

Merged
merged 3 commits into from
Oct 4, 2022

Conversation

Mike221002
Copy link
Contributor

To avoid the error:
app_1 | Traceback (most recent call last):
app_1 | File "/app/notifiers/smtp.py", line 38, in init
app_1 | self._connect()
app_1 | File "/app/notifiers/smtp.py", line 53, in _connect
app_1 | self.server = smtplib.SMTP_SSL(self.host, self.port)
app_1 | File "/usr/local/lib/python3.9/smtplib.py", line 1050, in init
app_1 | SMTP.init(self, host, port, local_hostname, timeout,
app_1 | File "/usr/local/lib/python3.9/smtplib.py", line 255, in init
app_1 | (code, msg) = self.connect(host, port)
app_1 | File "/usr/local/lib/python3.9/smtplib.py", line 341, in connect
app_1 | self.sock = self._get_socket(host, port, self.timeout)
app_1 | File "/usr/local/lib/python3.9/smtplib.py", line 1057, in _get_socket
app_1 | new_socket = self.context.wrap_socket(new_socket,
app_1 | File "/usr/local/lib/python3.9/ssl.py", line 501, in wrap_socket
app_1 | return self.sslsocket_class._create(
app_1 | File "/usr/local/lib/python3.9/ssl.py", line 1041, in _create
app_1 | self.do_handshake()
app_1 | File "/usr/local/lib/python3.9/ssl.py", line 1310, in do_handshake
app_1 | self._sslobj.do_handshake()
app_1 | ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)
app_1 |
app_1 | During handling of the above exception, another exception occurred:
app_1 |
app_1 | Traceback (most recent call last):
app_1 | File "/app/scanner.py", line 246, in
app_1 | main()
app_1 | File "/app/scanner.py", line 231, in main
app_1 | scanner = Scanner()
app_1 | File "/app/scanner.py", line 74, in init
app_1 | self.notifiers = Notifiers(self.config)
app_1 | File "/app/notifiers/init.py", line 15, in init
app_1 | self.smtp = SMTP(config)
app_1 | File "/app/notifiers/smtp.py", line 40, in init
app_1 | raise SMTPConfigurationError(exc.message) from exc
app_1 | AttributeError: 'ssl.SSLError' object has no attribute 'message'
tgtg_app_1 exited with code 1

To avoid the error:
app_1  | Traceback (most recent call last):
app_1  |   File "/app/notifiers/smtp.py", line 38, in __init__
app_1  |     self._connect()
app_1  |   File "/app/notifiers/smtp.py", line 53, in _connect
app_1  |     self.server = smtplib.SMTP_SSL(self.host, self.port)
app_1  |   File "/usr/local/lib/python3.9/smtplib.py", line 1050, in __init__
app_1  |     SMTP.__init__(self, host, port, local_hostname, timeout,
app_1  |   File "/usr/local/lib/python3.9/smtplib.py", line 255, in __init__
app_1  |     (code, msg) = self.connect(host, port)
app_1  |   File "/usr/local/lib/python3.9/smtplib.py", line 341, in connect
app_1  |     self.sock = self._get_socket(host, port, self.timeout)
app_1  |   File "/usr/local/lib/python3.9/smtplib.py", line 1057, in _get_socket
app_1  |     new_socket = self.context.wrap_socket(new_socket,
app_1  |   File "/usr/local/lib/python3.9/ssl.py", line 501, in wrap_socket
app_1  |     return self.sslsocket_class._create(
app_1  |   File "/usr/local/lib/python3.9/ssl.py", line 1041, in _create
app_1  |     self.do_handshake()
app_1  |   File "/usr/local/lib/python3.9/ssl.py", line 1310, in do_handshake
app_1  |     self._sslobj.do_handshake()
app_1  | ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)
app_1  |
app_1  | During handling of the above exception, another exception occurred:
app_1  |
app_1  | Traceback (most recent call last):
app_1  |   File "/app/scanner.py", line 246, in <module>
app_1  |     main()
app_1  |   File "/app/scanner.py", line 231, in main
app_1  |     scanner = Scanner()
app_1  |   File "/app/scanner.py", line 74, in __init__
app_1  |     self.notifiers = Notifiers(self.config)
app_1  |   File "/app/notifiers/__init__.py", line 15, in __init__
app_1  |     self.smtp = SMTP(config)
app_1  |   File "/app/notifiers/smtp.py", line 40, in __init__
app_1  |     raise SMTPConfigurationError(exc.message) from exc
app_1  | AttributeError: 'ssl.SSLError' object has no attribute 'message'
tgtg_app_1 exited with code 1
@Der-Henning
Copy link
Owner

Hi @Mike221002.
Thank you for your contribution! Didn't see this obvious mistake in confusing TLS and SSL...
I guess we need a config option for each TLS and SSL. I will create a code review tomorrow.

@Der-Henning
Copy link
Owner

Can you confirm it is working for you with the changes I made? Note the new TLS and SSL settings in the config.ini.

@Mike221002
Copy link
Contributor Author

I can confirm that the change work fine. Thank you for your fast change.

@Der-Henning
Copy link
Owner

Thank you. I will merge to main and create a new release tomorrow.

@Der-Henning Der-Henning merged commit b643c0a into Der-Henning:main Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants