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

[BUG] Runtime License Key not found when using MultiPythonPlugin and Cross-Platform #1599

Closed
fadebek opened this issue Nov 16, 2023 · 3 comments
Labels

Comments

@fadebek
Copy link

fadebek commented Nov 16, 2023

Hi, when I run my obfuscated script that needs a runtime license key, I have to explicitly set the PYARMOR_RKEY path to the location of the key. However, in the docs, it says that I should be able to just drop it in the runtime folder, but that doesn't work. Is this expected?

Steps to reproduce (using examples/testpkg):

  1. pyarmor cfg plugins=MultiPythonPlugin
  2. pyarmor gen -i -r --outer testpkg/mypkg -O obfpkg --platform darwin.aarch64 --platform linux.x86_64
  3. pyarmor gen key -e .1 -O obfpkg/mypkg/pyarmor_runtime_005114
  4. cp testpkg/main.py obfpkg
  5. python obfpkg/main.py

Yields RuntimeError: missing license key to run the script (1:10601)

However, if I do PYARMOR_RKEY=obfpkg/mypkg/pyarmor_runtime_005114 python obfpkg/main.py then it runs fine.

This is on PyArmor 8.4.3 on M2 Mac. Python 3.10. Thanks

@fadebek fadebek added the bug label Nov 16, 2023
@jondy
Copy link
Contributor

jondy commented Nov 17, 2023

If enable MultiPythonPlugin and multiple platforms, it need copy key file to each sub-folder. For example,

cp obfpkg/mypkg/pyarmor_runtime_005114/pyarmor.rkey obfpkg/mypkg/pyarmor_runtime_005114/py310
cp obfpkg/mypkg/pyarmor_runtime_005114/pyarmor.rkey obfpkg/mypkg/pyarmor_runtime_005114/py311
cp obfpkg/mypkg/pyarmor_runtime_005114/pyarmor.rkey obfpkg/mypkg/pyarmor_runtime_005114/py312

I'll documented it.

@jondy
Copy link
Contributor

jondy commented Nov 17, 2023

The other solution is to customize keyname with prefix ../, so the obfuscated scripts will search parent folder of py310.

For example,

$ pyarmor cfg outer_keyname=../pyarmor.rkey

# It's better to use +, do not disable the default CodeSignPlugin
$ pyarmor cfg plugins + MultiPythonPlugin                          

$ pyarmor gen -i  -r --outer testpkg/mypkg -O obfpkg --platform darwin.aarch64 --platform linux.x86_64                             

# make sure keyfile is stored at runtime package
$ pyarmor gen key -e .1 -O obfpkg/mypkg/pyarmor_runtime_005114/py310

$  cp testpkg/main.py obfpkg                                      
$  python obfpkg/main.py  

@jondy jondy closed this as completed Nov 17, 2023
@fadebek
Copy link
Author

fadebek commented Nov 17, 2023

Thanks. The first method worked. The second method gave me RuntimeError: unauthorized use of script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants