Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions proton/keyring_linux/core/keyring_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
"""
import json
import base64
import logging

import keyring
Expand Down Expand Up @@ -65,7 +66,7 @@ def _get_item(self, key):
raise KeyError(key)

try:
return json.loads(stored_data)
return json.loads(base64.b64decode(stored_data).decode("utf-8"))
except json.JSONDecodeError as excp:
# Delete data (it's invalid anyway)
self._del_item(key)
Expand All @@ -82,7 +83,8 @@ def _del_item(self, key):
raise KeyringError(excp) from excp

def _set_item(self, key, value):
json_data = json.dumps(value)
value = json.dumps(value)
json_data = base64.b64encode(value.encode("utf-8")).decode("utf-8")
try:
self.__keyring_backend.set_password(
self.KEYRING_SERVICE,
Expand Down
3 changes: 2 additions & 1 deletion proton/keyring_linux/secretservice/secretservice_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
"""
import json
import base64

import logging
import keyring
Expand Down Expand Up @@ -70,7 +71,7 @@ def _get_item(self, key):
raise KeyError(key)

try:
return json.loads(stored_data)
return json.loads(base64.b64decode(stored_data).decode("utf-8"))
except json.JSONDecodeError:
# gnome-keyring has a bug when processing new lines.
# Anytime we store the data to the keyring, we store all newlines in
Expand Down