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

Fix tkinter and check for load_pkcs12 on Linux #311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions devices/linux/Files/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def byte_to_string(barray: List) -> str:

try:
from OpenSSL import crypto
crypto.load_pkcs12 # missing in newer versions
except (ImportError, AttributeError): # AttributeError sometimes thrown by old/broken OpenSSL versions
CRYPTO_AVAILABLE = False

Expand Down Expand Up @@ -443,9 +444,13 @@ def prompt_nonempty_string(self, show: int, prompt: str, val: str = '') -> str:
return output
elif self.graphics == 'tkinter':
from tkinter import simpledialog
simpledialog.askstring(Config.title, prompt,
initialvalue=val,
show="*" if show == 0 else "")
while True:
output = simpledialog.askstring(Config.title, prompt,
initialvalue=val,
show="*" if show == 0 else "")
if output:
return output

else:
command = []
if self.graphics == 'zenity':
Expand Down Expand Up @@ -755,6 +760,14 @@ def __select_p12_file(self) -> str:
shell_command = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
cert, _ = shell_command.communicate()
if self.graphics == 'tkinter':
from tkinter import filedialog as fd
return fd.askopenfilename(title=Messages.p12_title,
filetypes=(("Certificate file",
("*.p12", "*.P12", "*.pfx",
"*.PFX")),))


return cert.decode('utf-8').strip()

@staticmethod
Expand Down