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

Implement aiohttp.client_exceptions.CertificateError and aiohttp.client_exceptions.SSLError #2294

Closed
hellysmile opened this issue Sep 28, 2017 · 2 comments
Labels

Comments

@hellysmile
Copy link
Member

Long story short

My idea is implement 2 new exceptions aiohttp.client_exceptions.CertificateError and aiohttp.client_exceptions.SSLError which has bases ssl.CertificateError and ssl.SSLError as well aiohttp.client_exceptions.ClientOSError. When users catch aiohttp.client_exceptions.ClientOSError there is no way to understand is it ssl error, dns error or networking error or whatever else

There is a list of all exceptions and their bases in ssl module

<class 'ssl.CertificateError'> (<class 'ValueError'>,)
<class 'ssl.SSLEOFError'> (<class 'ssl.SSLError'>,)
<class 'ssl.SSLError'> (<class 'OSError'>,)
<class 'ssl.SSLSyscallError'> (<class 'ssl.SSLError'>,)
<class 'ssl.SSLWantReadError'> (<class 'ssl.SSLError'>,)
<class 'ssl.SSLWantWriteError'> (<class 'ssl.SSLError'>,)
<class 'ssl.SSLZeroReturnError'> (<class 'ssl.SSLError'>,)

Expected behaviour

aiohttp.client_exceptions.CertificateError: Cannot connect to host expired.badssl.com:443 ssl:True [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)]

Actual behaviour

will raise

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host expired.badssl.com:443 ssl:True [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)]

import aiohttp
import asyncio

async def main():
    async with aiohttp.ClientSession() as session:
        async with session.get('https://expired.badssl.com/') as response:
            return await response.text()

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Your environment

Python 3.6.2
Mac OS X 10.12.6
latest aiohttp master branch

@asvetlov
Copy link
Member

Fixed by #2297

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants