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

BUG. ssl.SSLError: [SSL: KRB5_S_INIT] application data after close notify #3502

Closed
5 tasks done
ghost opened this issue Jan 8, 2019 · 3 comments
Closed
5 tasks done

Comments

@ghost
Copy link

ghost commented Jan 8, 2019

Long story short

If assert is between function where I use ClientSession() -> this give error to me:

SSL error in data received  
protocol: <asyncio.sslproto.SSLProtocol object at 0x7f27f8585ac8>  
transport: <_SelectorSocketTransport fd=38 read=polling write=<idle, bufsize=0>>  
Traceback (most recent call last):  
  File "/usr/lib/python3.7/asyncio/sslproto.py", line 526, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/lib/python3.7/asyncio/sslproto.py", line 207, in feed_ssldata
    self._sslobj.unwrap()
  File "/usr/lib/python3.7/ssl.py", line 767, in unwrap
    return self._sslobj.shutdown()
ssl.SSLError: [SSL: KRB5_S_INIT] application data after close notify (_ssl.c:2592)

Expected behaviour

No errors, I am using try..catch

Actual behaviour

Show me error message in console.

Steps to reproduce

import asyncio
from aiohttp import ClientSession, ClientTimeout


async def fun3(url):
    try:
        async with ClientSession(timeout=timeout) as s:
            async with s.get(url) as r:
                if r.status == 200:
                    return True
                else:
                    return False
    except:
        return False


async def fun1(session, url):
    try:
        async with session.get(url) as r:
            # Make assert here, special. And error displayed
            assert 'A77er1 9rr0r' in await r.text()

        return [True, url]
    except:
        return [False, '']


async def fun0(url):
    url = url if 'http' in url else 'http://' + url

    # If I remove this function - all good
    if await fun3(url):
        return

    async with ClientSession(timeout=timeout) as s:
        temp = await fun1(s, url)

        if temp[0]:
            print('Good')


async def main():
    tasks = []
    # I have many items, just add to simulate real behavior
    task = asyncio.create_task(
        fun0(
            'https://python.org'
        )
    )
    tasks.append(task)

    await asyncio.gather(*tasks)


if __name__ == "__main__":
    timeout = ClientTimeout(total=10)

    asyncio.run(main())

Your environment

  • Ubuntu 18.04

  • Python 3.7.1

  • GCC 8.2.0

  • asyncio v3.4.3

  • aiohttp v3.5.1

@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #3477 ("Application data after close notify" regression in 3.5.0 with SSL connection), #2497 (ClientSession keep transferring data after closed), #3052 (SSL with closed connections), #370 (Server closes connection before sending data), and #1907 (aiohttp 2.x closing client request data stream).

@asvetlov
Copy link
Member

asvetlov commented Jan 8, 2019

A copy of #3477

@lock
Copy link

lock bot commented Jan 8, 2020

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.

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

No branches or pull requests

2 participants