TLS error handling

This commit is contained in:
ed 2019-06-25 23:21:15 +00:00
parent b0c2fc91b2
commit 0bfb778446
2 changed files with 24 additions and 4 deletions

View file

@ -3,6 +3,7 @@
* http file sharing hub (py2/py3) * http file sharing hub (py2/py3)
* MIT-Licensed, 2019-05-26, ed @ irc.rizon.net * MIT-Licensed, 2019-05-26, ed @ irc.rizon.net
## summary ## summary
turn your phone or raspi into a portable file server with resumable uploads/downloads using IE6 or any other browser turn your phone or raspi into a portable file server with resumable uploads/downloads using IE6 or any other browser
@ -11,6 +12,7 @@ turn your phone or raspi into a portable file server with resumable uploads/down
* *resumable* uploads need `firefox 12+` / `chrome 6+` / `safari 6+` / `IE 10+` * *resumable* uploads need `firefox 12+` / `chrome 6+` / `safari 6+` / `IE 10+`
* code standard: `black` * code standard: `black`
## status ## status
* [x] sanic multipart parser * [x] sanic multipart parser
@ -49,6 +51,7 @@ after the initial setup (and restarting bash), you can launch copyparty at any t
# dev env setup # dev env setup
```sh ```sh
python3 -m venv .env python3 -m venv .env
. .env/bin/activate . .env/bin/activate
@ -58,6 +61,15 @@ pip install black bandit pylint flake8 # vscode tooling
``` ```
# how to release
in the `scripts` folder:
* run `make -C deps-docker` to build all dependencies
* create github release with `make-tgz-release.sh`
* upload to pypi with `make-pypi-release.(sh|bat)`
# immediate todo # immediate todo
roughly sorted by priority roughly sorted by priority

View file

@ -46,11 +46,11 @@ class HttpConn(object):
if self.cert_path: if self.cert_path:
method = self.s.recv(4, socket.MSG_PEEK) method = self.s.recv(4, socket.MSG_PEEK)
if len(method) != 4: if len(method) != 4:
err = b"need at least 4 bytes in the first packet; got {}".format( err = "need at least 4 bytes in the first packet; got {}".format(
len(method) len(method)
) )
self.log(err) self.log(err)
self.s.send(b"HTTP/1.1 400 Bad Request\r\n\r\n" + err) self.s.send(b"HTTP/1.1 400 Bad Request\r\n\r\n" + err.encode("utf-8"))
return return
if method not in [None, b"GET ", b"HEAD", b"POST"]: if method not in [None, b"GET ", b"HEAD", b"POST"]:
@ -60,10 +60,18 @@ class HttpConn(object):
self.s, server_side=True, certfile=self.cert_path self.s, server_side=True, certfile=self.cert_path
) )
except Exception as ex: except Exception as ex:
if "ALERT_BAD_CERTIFICATE" in str(ex): em = str(ex)
if "ALERT_BAD_CERTIFICATE" in em:
# firefox-linux if there is no exception yet
self.log("client rejected our certificate (nice)") self.log("client rejected our certificate (nice)")
elif "ALERT_CERTIFICATE_UNKNOWN" in em:
# chrome-android keeps doing this
pass
else: else:
self.log("\033[35mhandshake\033[0m " + str(ex)) self.log("\033[35mhandshake\033[0m " + em)
return return