Skip to content

Commit

Permalink
🔐 SSL termination handling (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgonzo27 committed Sep 7, 2022
1 parent 767491e commit d6694a3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/public/static/changelog/iotFtpsClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ title: iot-ftps-client Changelog

# Release History for iot-ftps-client

### 1.1.0 (09/07/2022)

- Override `storbinary` function to prevent implicit SSL shutdown

### 1.0.1 (08/30/2022)

- Bug fix for uploading byte streams from within a context
Expand Down
4 changes: 4 additions & 0 deletions iot-ftps-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 1.1.0 (09/07/2022)

- Override `storbinary` function to prevent implicit SSL shutdown

## 1.0.1 (08/30/2022)

- Bug fix for uploading byte streams from within a context
Expand Down
19 changes: 19 additions & 0 deletions iot-ftps-client/iot/ftps/client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ def sock(self, value):
value = self.context.wrap_socket(value)
self._sock = value

def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
"""
override storbinary to prevent SSL shutdown
(https://github.com/python/cpython/blob/main/Lib/ftplib.py)
"""
self.voidcmd("TYPE I")
with self.transfercmd(cmd, rest) as conn:
while 1:
buf = fp.read(blocksize)
if not buf:
break
conn.sendall(buf)
if callback:
callback(buf)
# THIS IS WHERE WE OVERRIDE
# if _SSLSocket is not None and isinstance(conn, _SSLSocket):
# conn.unwrap()
return self.voidresp()


class IoTFTPSClient:
"""iot ftps client"""
Expand Down
2 changes: 1 addition & 1 deletion iot-ftps-client/iot/ftps/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = "1.0.1"
VERSION = "1.1.0"

__version__ = VERSION

0 comments on commit d6694a3

Please sign in to comment.