kurtbrose / pyjks

a pure python Java KeyStore file parser, including private key decryption
MIT License
130 stars 35 forks source link

Does not work on Python 2.7 with javaobj-py3==0.3.0 #47

Open danpker opened 5 years ago

danpker commented 5 years ago

I'm not sure why this issue is happening but you can replicate it by running the tests on Python 2 with javaobj-py3==0.3.0.

You get the following exception: UnexpectedAlgorithmException: Unexpected algorithm used for encrypting SealedObject: sealAlg=PBEWithMD5AndTripleDES.

Using javaobj-py3==0.2.4 works correctly. This is hard to see because the requirements file in this repo pins that dependancy to 0.2.1, whereas the setup.py file makes no specification.

mahmoud commented 5 years ago

Hey @danpker! This is Interesting.

How far did you have to downgrade to get it working? Shall we open an issue over on javaobj? I see 0.3.0 just came out a couple days ago.

I guess one fix in the meantime would be to change the install_requires to be javaobj-py3<0.3.0.

danpker commented 5 years ago

@mahmoud I have got it working on 0.2.4, and fixing it at that version has worked for me. I'm not sure where the root cause of the issue is (whether it is in pyjks or javaobj)

cory-parr commented 5 years ago

I believe I tracked the source of the problem down to a change they made in 0.3.0: https://github.com/tcalmant/python-javaobj/issues/26

This causes a comparison failure here: https://github.com/kurtbrose/pyjks/blob/v18.0.0/jks/jks.py#L303

mahmoud commented 5 years ago

Wow, thank you @cory-parr! That makes perfect sense, very cogent.

Kind of a big change for a minor release, but it's wild times in 0ver-land.

But at least we have a potential second option (other than pinning <0.3.0): maybe we can fix with from __future__ import unicode_literals (or just plain unicode literals, though that can be hard to keep track), then pin to javaobj>=0.3.0.

Any volunteers to test/PR that approach?