Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acsm file loading into calibre instead of being "converted" to epub #23

Closed
junefish opened this issue May 15, 2022 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@junefish
Copy link

Bug description

The plugin works great on my Windows 10 desktop computer, and I authorised it with ADE there. I exported all calibre data and imported it into calibre on my Linux laptop (running Pop! OS 22.04 LTS). Here is the output of running calibre-debug --gui and then adding an .acsm file:

DeACSM v0.0.15: Try to fulfill ...
Running file type plugin DeACSM failed with traceback:
Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 175, in _run_filetype_plugins
    nfp = plugin.run(nfp) or nfp
  File "calibre_plugins.deacsm.__init__", line 385, in run
    success, replyData = fulfill(path_to_ebook, deacsmprefs["notify_fulfillment"])
  File "/home/citizenfour/.config/calibre/plugins/DeACSM.zip/libadobeFulfill.py", line 380, in fulfill
    signature = sign_node(fulfill_request_xml)
  File "/home/citizenfour/.config/calibre/plugins/DeACSM.zip/libadobe.py", line 518, in sign_node
    my_priv_key, _, _ = keys.parse_pkcs12(my_pkcs12, base64.b64encode(devkey_bytes))
  File "/home/citizenfour/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/asymmetric.py", line 774, in
parse_pkcs12
    return _parse_pkcs12(data, password, load_private_key)
  File "/home/citizenfour/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 866, in _parse_pkcs12
    decrypted_content = _decrypt_encrypted_data(encryption_algorithm_info, encrypted_content, password)
  File "/home/citizenfour/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 1036, in
_decrypt_encrypted_data
    plaintext = decrypt_func(enc_key, encrypted_content, enc_iv)
  File "/home/citizenfour/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/symmetric.py", line 364, in
rc2_cbc_pkcs5_decrypt
    return _decrypt('rc2', key, data, iv, True)
  File "/home/citizenfour/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/symmetric.py", line 750, in _decrypt
    handle_openssl_error(res)
  File "/home/citizenfour/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 86, in
handle_openssl_error
    raise exception_class(_try_decode(error_string))
OSError: error:0308010C:digital envelope routines::unsupported
Added TheModernWitchcraftG 9781507211496 4630375 to db in: 0.0
Added 1 books in 0.7 seconds

Operating system

Linux

Which version of Calibre are you running?

5.37

Which version of the DeACSM plugin are you running?

0.0.15

Further information

This seems similar to issue #19 but I'm not sure so am filing a new issue rather than reopening that one.

@JJTech0130
Copy link

Searching that error code it seem to be related to OpenSSL. I don’t think it’s related to #19, as that was about requests to the server.
I see a mention of RC2 in the logs, and searching the error comes up with things about OpenSSL legacy provider, so it’s probably related to #20

@JJTech0130
Copy link

JJTech0130 commented May 15, 2022

@junefish did you try the latest build from actions? Looking through #20, it looks like there is a known issue with Ubuntu and PopOS 22. Here’s a direct link: https://github.com/Leseratte10/acsm-calibre-plugin/suites/6507668348/artifacts/241937660

@junefish
Copy link
Author

@JJTech0130 thanks, issue #20 didn't come up in my search. I deleted the existing plugin, restarted calibre, downloaded the zip you linked, unzipped + installed into calibre, and then quit calibre and ran with calibre-debug. It's still showing up as 0.0.15 so I'm assuming it's a new version without a new version number?

Anyway, that worked!! Thanks a lot. Here's the output in case this helps anyone else:

DeACSM v0.0.15: Trying to parse file TheModernWitchcraftG_9781507211496_4630375.acsm
DeACSM v0.0.15: Try to fulfill ...
Not notifying any server since that was disabled.
DeACSM v0.0.15: Downloading book ...
DeACSM v0.0.15: Loading book from https://acs.cdn.overdrive.com/ACSStore1/0439-1/F38/8DD/38/{F388DD38-4AEF-4920-98D9-1AAAB681966A}Fmt410.epub
Download took 5196 ms (HTTP 200)
That's a ZIP file -> EPUB
DeACSM v0.0.15: File successfully fulfilled ...
DeACSM v0.0.15: Executing plugin DeDRM ...
DeDRM v10.0.2: Trying to decrypt izj2tr4f.epub
DeDRM v10.0.2: Verifying zip archive integrity
DeDRM v10.0.2: izj2tr4f.epub is a secure Adobe Adept ePub for UUID 6be4f782-62e2-403f-bec3-259c336e4cb3
DeDRM v10.0.2: Trying UUID-matched encryption key adobe_uuid_6be4f782-62e2-403f-bec3-259c336e4cb3
DeDRM v10.0.2: Decrypted with key adobe_uuid_6be4f782-62e2-403f-bec3-259c336e4cb3 after 1.2 seconds
DeDRM v10.0.2: Finished after 1.2 seconds
DeACSM v0.0.15: Plugin returned path '/tmp/calibre_5.37.0_tmp_9l0j6978/4vu9vzct.epub', updating.
Added The Modern Witchcraft Guide to Magickal Herbs: Your Complete Guide to the Hidden Powers of Herbs to db in: 0.1
Added 1 books in 7.5 seconds

@JJTech0130
Copy link

Yeah it’s just the latest beta build from the master branch. I’m assuming @Leseratte10 will release it and give it a version soon.

@Leseratte10
Copy link
Owner

Leseratte10 commented May 16, 2022

I'm surprised that the OpenSSL issue can lead to different error messages. Great that the existing beta worked in this case, too. Looks like the oscrypto module was unable to figure out the OpenSSL version for some reason and then just attempted to use RC2 encryption despite that not being available.

The current method of getting OpenSSL to work is a terrible hack which I'd rather not have in an actual release that will be used by lots of people, so that will probably have to wait until my bugfix in the oscrypto library is merged so I no longer need to patch the existing library code from within my plugin.

@Leseratte10 Leseratte10 added the bug Something isn't working label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants