mirror of
https://github.com/Leseratte10/acsm-calibre-plugin
synced 2024-12-25 09:58:30 +01:00
Ignore cert errors during book download
Some checks failed
Build binaries / build (push) Has been cancelled
Build binaries / test-python3 (3.10) (push) Has been cancelled
Build binaries / test-python3 (3.11) (push) Has been cancelled
Build binaries / test-python3 (3.12) (push) Has been cancelled
Build binaries / test-python3 (3.6) (push) Has been cancelled
Build binaries / test-python3 (3.7) (push) Has been cancelled
Build binaries / test-python3 (3.8) (push) Has been cancelled
Build binaries / test-python3 (3.9) (push) Has been cancelled
Build binaries / test-python2 (push) Has been cancelled
Build binaries / test-ubuntu-2004 (push) Has been cancelled
Build binaries / test-ubuntu-2204-oscrypto (push) Has been cancelled
Build binaries / test-ubuntu-2204-oscrypto-fork (push) Has been cancelled
Build binaries / test-windows (push) Has been cancelled
Build binaries / test-mac (push) Has been cancelled
Some checks failed
Build binaries / build (push) Has been cancelled
Build binaries / test-python3 (3.10) (push) Has been cancelled
Build binaries / test-python3 (3.11) (push) Has been cancelled
Build binaries / test-python3 (3.12) (push) Has been cancelled
Build binaries / test-python3 (3.6) (push) Has been cancelled
Build binaries / test-python3 (3.7) (push) Has been cancelled
Build binaries / test-python3 (3.8) (push) Has been cancelled
Build binaries / test-python3 (3.9) (push) Has been cancelled
Build binaries / test-python2 (push) Has been cancelled
Build binaries / test-ubuntu-2004 (push) Has been cancelled
Build binaries / test-ubuntu-2204-oscrypto (push) Has been cancelled
Build binaries / test-ubuntu-2204-oscrypto-fork (push) Has been cancelled
Build binaries / test-windows (push) Has been cancelled
Build binaries / test-mac (push) Has been cancelled
Fixes #97
This commit is contained in:
parent
2dcf26be18
commit
2f40289a84
1 changed files with 23 additions and 1 deletions
|
@ -252,8 +252,26 @@ def sendHTTPRequest_DL2FILE(URL, outputfile):
|
|||
"User-Agent": "book2png",
|
||||
# MacOS uses different User-Agent. Good thing we're emulating a Windows client.
|
||||
}
|
||||
|
||||
# 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.
|
||||
try:
|
||||
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
||||
# This is needed due to an Adobe change.
|
||||
# Without this, only Python <= 3.7.16 can connect, 3.7.17 and above fail.
|
||||
# Cloudflare detects that Python uses TLS1.3 which ADE doesn't support, so
|
||||
# just enforce TLSv1.2 here.
|
||||
except:
|
||||
ctx = ssl.create_default_context()
|
||||
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
|
||||
req = ulib.Request(url=URL, headers=headers)
|
||||
handler = ulib.urlopen(req)
|
||||
handler = ulib.urlopen(req, context=ctx)
|
||||
|
||||
chunksize = 16 * 1024
|
||||
|
||||
|
@ -298,6 +316,8 @@ def sendHTTPRequest_getSimple(URL):
|
|||
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
||||
# This is needed due to an Adobe change.
|
||||
# Without this, only Python <= 3.7.16 can connect, 3.7.17 and above fail.
|
||||
# Cloudflare detects that Python uses TLS1.3 which ADE doesn't support, so
|
||||
# just enforce TLSv1.2 here.
|
||||
except:
|
||||
ctx = ssl.create_default_context()
|
||||
|
||||
|
@ -338,6 +358,8 @@ def sendPOSTHTTPRequest(URL, document, type, returnRC = False):
|
|||
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
||||
# This is needed due to an Adobe change.
|
||||
# Without this, only Python <= 3.7.16 can connect, 3.7.17 and above fail.
|
||||
# Cloudflare detects that Python uses TLS1.3 which ADE doesn't support, so
|
||||
# just enforce TLSv1.2 here.
|
||||
except:
|
||||
ctx = ssl.create_default_context()
|
||||
|
||||
|
|
Loading…
Reference in a new issue