serve: Improve error handling on /set_service_certificate
This commit is contained in:
parent
2c33af79df
commit
796cf7ffb0
|
@ -3,6 +3,8 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
|
from google.protobuf.message import DecodeError
|
||||||
|
|
||||||
from pywidevine.pssh import PSSH
|
from pywidevine.pssh import PSSH
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -18,7 +20,7 @@ except ImportError:
|
||||||
from pywidevine import __version__
|
from pywidevine import __version__
|
||||||
from pywidevine.cdm import Cdm
|
from pywidevine.cdm import Cdm
|
||||||
from pywidevine.device import Device
|
from pywidevine.device import Device
|
||||||
from pywidevine.exceptions import TooManySessions, InvalidSession
|
from pywidevine.exceptions import TooManySessions, InvalidSession, SignatureMismatch
|
||||||
from pywidevine.license_protocol_pb2 import LicenseType, License
|
from pywidevine.license_protocol_pb2 import LicenseType, License
|
||||||
|
|
||||||
routes = web.RouteTableDef()
|
routes = web.RouteTableDef()
|
||||||
|
@ -155,6 +157,16 @@ async def set_service_certificate(request: web.Request) -> web.Response:
|
||||||
"status": 400,
|
"status": 400,
|
||||||
"message": f"Invalid Session ID '{session_id.hex()}', it may have expired."
|
"message": f"Invalid Session ID '{session_id.hex()}', it may have expired."
|
||||||
}, status=400)
|
}, status=400)
|
||||||
|
except DecodeError as e:
|
||||||
|
return web.json_response({
|
||||||
|
"status": 400,
|
||||||
|
"message": f"Invalid Service Certificate, {e}"
|
||||||
|
}, status=400)
|
||||||
|
except SignatureMismatch:
|
||||||
|
return web.json_response({
|
||||||
|
"status": 400,
|
||||||
|
"message": "Signature Validation failed on the Service Certificate, rejecting."
|
||||||
|
}, status=400)
|
||||||
|
|
||||||
return web.json_response({
|
return web.json_response({
|
||||||
"status": 200,
|
"status": 200,
|
||||||
|
|
Loading…
Reference in New Issue