[issue41597] Fatal Error on SSL Transport - sslv3 alert bad record mac

2020-08-24 Thread Mototsugu Emori


Mototsugu Emori  added the comment:

Thank you for your reply.
I understand that websocket cannot be used in multiple threads.
I close the issue.

--
stage:  -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue41597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41596] Re: Asyncio Fatal Error on SSL Transport - IndexError Deque Index Out Of Range

2020-08-24 Thread Mototsugu Emori


Mototsugu Emori  added the comment:

Thank you for your reply.
I understand that websocket cannot be used in multiple threads.
I close the issue.

--
stage:  -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue41596>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41597] Fatal Error on SSL Transport - sslv3 alert bad record mac

2020-08-20 Thread Mototsugu Emori


New submission from Mototsugu Emori :

When using SSL with websocket, I get an SSLError.

---
[2020-08-17 15:02:51,078] websockets.protocol : Error in data transfer 
[MainProcess - MainThread]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
827, in transfer_data
message = await self.read_message()
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
895, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
971, in read_data_frame
frame = await self.read_frame(max_size)
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
1051, in read_frame
extensions=self.extensions,
  File "/usr/local/lib/python3.7/site-packages/websockets/framing.py", line 
106, in read
data = await reader(2)
  File "/usr/local/lib/python3.7/asyncio/streams.py", line 679, in readexactly
await self._wait_for_data('readexactly')
  File "/usr/local/lib/python3.7/asyncio/streams.py", line 473, in 
_wait_for_data
await self._waiter
  File "guac_ws_client.py", line 166, in read
await websocket.send(instruction)
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
567, in send
await self.write_frame(True, opcode, data)
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
1077, in write_frame
await self._drain()
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
306, in _drain
raise exc
  File "/usr/local/lib/python3.7/asyncio/sslproto.py", line 530, in 
data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/local/lib/python3.7/asyncio/sslproto.py", line 202, in feed_ssldata
chunk = self._sslobj.read(self.max_size)
  File "/usr/local/lib/python3.7/ssl.py", line 707, in read
v = self._sslobj.read(len)
ssl.SSLError: [SSL: SSLV3_ALERT_BAD_RECORD_MAC] sslv3 alert bad record mac 
(_ssl.c:2488)
---

When data reception (SSL_read) and data transmission (SSL_write) occur at the 
same time, the error seems to occur.
I made a patch(ssl.py.patch) that excludes SSL_read and SSL_write.
Could you check it?

Environments:
  debian 4.19.46
  Python 3.7.3
  OpenSSL 1.1.0l  10 Sep 2019

Reference:
  Re: Asyncio Fatal Error on SSL Transport - IndexError Deque Index Out Of Range
  https://bugs.python.org/issue41596

--
assignee: christian.heimes
components: SSL
files: ssl.py.patch
keywords: patch
messages: 375690
nosy: alex, christian.heimes, dstufft, janssen, m_emori
priority: normal
severity: normal
status: open
title: Fatal Error on SSL Transport - sslv3 alert bad record mac
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file49410/ssl.py.patch

___
Python tracker 
<https://bugs.python.org/issue41597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41596] Re: Asyncio Fatal Error on SSL Transport - IndexError Deque Index Out Of Range

2020-08-20 Thread Mototsugu Emori


New submission from Mototsugu Emori :

When using SSL with websocket, _process_write_backlog function throws 
IndexError.

---
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
827, in transfer_data
message = await self.read_message()
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
895, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
971, in read_data_frame
frame = await self.read_frame(max_size)
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 
1051, in read_frame
extensions=self.extensions,
  File "/usr/local/lib/python3.7/site-packages/websockets/framing.py", line 
105, in read
data = await reader(2)
  File "/usr/local/lib/python3.7/asyncio/streams.py", line 679, in readexactly
await self._wait_for_data('readexactly')
  File "/usr/local/lib/python3.7/asyncio/streams.py", line 473, in 
_wait_for_data
await self._waiter
  File "/usr/local/lib/python3.7/asyncio/sslproto.py", line 689, in 
_process_write_backlog
del self._write_backlog[0]
IndexError: deque index out of range
---

Websocket has a keepalive feature and periodically pings the server.
If ping sending process occurs at the same time when sending data, the data 
operation to the array (_write_backlog) will be duplicated and the error will 
occur.

---
asyncio/sslproto.py
---
class SSLProtocol(protocols.Protocol)
def _write_appdata(self, data):
self._write_backlog.append((data, 0)) <--- append data to _write_backlog
self._write_buffer_size += len(data)
self._process_write_backlog()

def _process_write_backlog(self):
del self._write_backlog[0]  <--- !!!ERROR!!! IndexError: deque index 
out of range
---

I made a patch(sslproto.sy.patch) to exclude data operations on the array 
(_write_backlog).
Could you check it?

Environments:
  debian 4.19.46
  Python 3.7.3
  OpenSSL 1.1.0l  10 Sep 2019

Reference:
  Asyncio Fatal Error on SSL Transport - IndexError Deque Index Out Of Range
  https://bugs.python.org/issue37226

--
components: asyncio
files: sslproto.py.patch
keywords: patch
messages: 375689
nosy: asvetlov, ben.brown, christian.heimes, m_emori, maayank, yselivanov
priority: normal
severity: normal
status: open
title: Re: Asyncio Fatal Error on SSL Transport - IndexError Deque Index Out Of 
Range
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file49409/sslproto.py.patch

___
Python tracker 
<https://bugs.python.org/issue41596>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com