From 977b6951a3ebbf3c59a1fe5cee5107a70337dcbd Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Tue, 26 Oct 2021 08:03:33 +0200 Subject: [PATCH] Ignore SSL errors during ACS Notify Apparently some distributors aren't using SSL correctly (or it somehow gets messed up along the way) and the notification fails. There's nothing that needs to be kept secret in these notifications so we can ignore SSL errors to ensure that fulfillment works even when SSL isn't. --- calibre-plugin/libadobe.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/calibre-plugin/libadobe.py b/calibre-plugin/libadobe.py index 5d17f57..3d440c4 100644 --- a/calibre-plugin/libadobe.py +++ b/calibre-plugin/libadobe.py @@ -168,8 +168,17 @@ def sendHTTPRequest_getSimple(URL: str): "Accept": "*/*", "User-Agent": "book2png", } + + # Ignore SSL: + # It appears as if lots of book distributors have either invalid or expired certs ... + # No idea how Adobe handles that (pinning?), but we can just ignore SSL errors and continue anyways. + # Not the best solution, but it works. + ctx = ssl.create_default_context() + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE + req = urllib.request.Request(url=URL, headers=headers) - handler = urllib.request.urlopen(req) + handler = urllib.request.urlopen(req, context=ctx) content = handler.read() @@ -193,6 +202,9 @@ def sendPOSTHTTPRequest(URL: str, document: bytes, type: str, returnRC = False): } # Ignore SSL: + # It appears as if lots of book distributors have either invalid or expired certs ... + # No idea how Adobe handles that (pinning?), but we can just ignore SSL errors and continue anyways. + # Not the best solution, but it works. ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE