mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-22 17:29:56 +06:00
Display error message if pkcs12 can't be decrypted
This commit is contained in:
parent
dd104665bb
commit
53e106fa73
@ -189,7 +189,7 @@ class DeACSM(FileTypePlugin):
|
|||||||
|
|
||||||
from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest
|
from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest
|
||||||
from libadobeAccount import createDeviceFile, createUser, signIn, activateDevice
|
from libadobeAccount import createDeviceFile, createUser, signIn, activateDevice
|
||||||
from libadobeFulfill import buildRights, fulfill
|
from libadobeFulfill import buildRights, fulfill, getDecryptedCert
|
||||||
|
|
||||||
|
|
||||||
import calibre_plugins.deacsm.prefs as prefs # type: ignore
|
import calibre_plugins.deacsm.prefs as prefs # type: ignore
|
||||||
@ -215,25 +215,35 @@ class DeACSM(FileTypePlugin):
|
|||||||
import calibre_plugins.deacsm.prefs as prefs # type: ignore
|
import calibre_plugins.deacsm.prefs as prefs # type: ignore
|
||||||
deacsmprefs = prefs.DeACSM_Prefs()
|
deacsmprefs = prefs.DeACSM_Prefs()
|
||||||
|
|
||||||
activation_xml_path = os.path.join(deacsmprefs["path_to_account_data"], "activation.xml")
|
from libadobe import get_activation_xml_path
|
||||||
|
from libadobeFulfill import getDecryptedCert
|
||||||
|
|
||||||
container = None
|
container = None
|
||||||
try:
|
try:
|
||||||
container = etree.parse(activation_xml_path)
|
container = etree.parse(get_activation_xml_path())
|
||||||
except:
|
except:
|
||||||
|
print("ADE sanity check: Can't parse activation container")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
adeptNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
adeptNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
||||||
|
|
||||||
if container.find(adeptNS("activationToken")) == None:
|
if container.find(adeptNS("activationToken")) == None:
|
||||||
|
print("ADE sanity check: activationToken missing")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if container.find(adeptNS("credentials")).find(adeptNS("pkcs12")) == None:
|
if container.find(adeptNS("credentials")).find(adeptNS("pkcs12")) == None:
|
||||||
|
print("ADE sanity check: pkcs12 missing")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if getDecryptedCert() is None:
|
||||||
|
print("ADE sanity check: Can't decrypt pkcs12")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
print("ADE sanity check: Exception")
|
||||||
|
traceback.print_exc()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def download(self, replyData):
|
def download(self, replyData):
|
||||||
|
@ -511,6 +511,7 @@ class ConfigWidget(QWidget):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from libadobe import VAR_VER_SUPP_CONFIG_NAMES, VAR_VER_HOBBES_VERSIONS
|
from libadobe import VAR_VER_SUPP_CONFIG_NAMES, VAR_VER_HOBBES_VERSIONS
|
||||||
|
from libadobeFulfill import getDecryptedCert
|
||||||
except:
|
except:
|
||||||
print("{0} v{1}: Error while importing Account stuff".format(PLUGIN_NAME, PLUGIN_VERSION))
|
print("{0} v{1}: Error while importing Account stuff".format(PLUGIN_NAME, PLUGIN_VERSION))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
@ -564,6 +565,9 @@ class ConfigWidget(QWidget):
|
|||||||
if container.find(adeptNS("credentials")).find(adeptNS("pkcs12")) == None:
|
if container.find(adeptNS("credentials")).find(adeptNS("pkcs12")) == None:
|
||||||
return "ADE authorization seems to be corrupted (pkcs12 missing)", False, None
|
return "ADE authorization seems to be corrupted (pkcs12 missing)", False, None
|
||||||
|
|
||||||
|
if getDecryptedCert() is None:
|
||||||
|
return "ADE authorization seems to be corrupted (failed to decrypt pkcs12)", False, None
|
||||||
|
|
||||||
if not anon:
|
if not anon:
|
||||||
return "Authorized with ADE ID ("+ade_type+") " + ade_mail + "\non device " + ade_device_name + ", emulating " + ADE_version + ".", True, ade_mail
|
return "Authorized with ADE ID ("+ade_type+") " + ade_mail + "\non device " + ade_device_name + ", emulating " + ADE_version + ".", True, ade_mail
|
||||||
else:
|
else:
|
||||||
|
@ -137,8 +137,8 @@ def buildInitLicenseServiceRequest(authURL):
|
|||||||
|
|
||||||
return "<?xml version=\"1.0\"?>\n" + etree.tostring(req_xml, encoding="utf-8", pretty_print=True, xml_declaration=False).decode("utf-8")
|
return "<?xml version=\"1.0\"?>\n" + etree.tostring(req_xml, encoding="utf-8", pretty_print=True, xml_declaration=False).decode("utf-8")
|
||||||
|
|
||||||
def buildAuthRequest():
|
|
||||||
|
|
||||||
|
def getDecryptedCert():
|
||||||
activationxml = etree.parse(get_activation_xml_path())
|
activationxml = etree.parse(get_activation_xml_path())
|
||||||
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
||||||
|
|
||||||
@ -156,8 +156,20 @@ def buildAuthRequest():
|
|||||||
devkey_bytes = f.read()
|
devkey_bytes = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
try:
|
||||||
|
return get_cert_from_pkcs12(user_pkcs12, base64.b64encode(devkey_bytes))
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
my_cert = get_cert_from_pkcs12(user_pkcs12, base64.b64encode(devkey_bytes))
|
def buildAuthRequest():
|
||||||
|
|
||||||
|
activationxml = etree.parse(get_activation_xml_path())
|
||||||
|
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
||||||
|
|
||||||
|
my_cert = getDecryptedCert()
|
||||||
|
if my_cert is None:
|
||||||
|
print("Can't decrypt pkcs12 with devkey!")
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
ret = "<?xml version=\"1.0\"?>\n"
|
ret = "<?xml version=\"1.0\"?>\n"
|
||||||
@ -177,6 +189,10 @@ def doOperatorAuth(operatorURL):
|
|||||||
|
|
||||||
auth_req = buildAuthRequest()
|
auth_req = buildAuthRequest()
|
||||||
|
|
||||||
|
if auth_req is None:
|
||||||
|
return "Failed to create auth request"
|
||||||
|
|
||||||
|
|
||||||
authURL = operatorURL
|
authURL = operatorURL
|
||||||
if authURL.endswith("Fulfill"):
|
if authURL.endswith("Fulfill"):
|
||||||
authURL = authURL.replace("/Fulfill", "")
|
authURL = authURL.replace("/Fulfill", "")
|
||||||
|
Loading…
Reference in New Issue
Block a user