mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
added functions for storing/loading signer fingerprints to stats
This commit is contained in:
parent
5a524d4d0c
commit
bca07f794f
4 changed files with 266 additions and 1 deletions
|
@ -36,6 +36,7 @@ import socket
|
|||
import base64
|
||||
import zipfile
|
||||
import tempfile
|
||||
import json
|
||||
import xml.etree.ElementTree as XMLElementTree
|
||||
|
||||
from binascii import hexlify
|
||||
|
@ -2552,6 +2553,34 @@ def get_certificate(certificate_file):
|
|||
return encoder.encode(cert)
|
||||
|
||||
|
||||
def load_stats_fdroid_signing_key_fingerprints():
|
||||
"""Load list of signing-key fingerprints stored by fdroid publish from file.
|
||||
|
||||
:returns: list of dictionanryies containing the singing-key fingerprints.
|
||||
"""
|
||||
jar_file = os.path.join('stats', 'publishsigkeys.jar')
|
||||
if not os.path.isfile(jar_file):
|
||||
return {}
|
||||
cmd = [config['jarsigner'], '-strict', '-verify', jar_file]
|
||||
p = FDroidPopen(cmd, output=False)
|
||||
if p.returncode != 4:
|
||||
raise FDroidException("Signature validation of '{}' failed! "
|
||||
"Please run publish again to rebuild this file.".format(jar_file))
|
||||
|
||||
jar_sigkey = apk_signer_fingerprint(jar_file)
|
||||
repo_key_sig = config.get('repo_key_sha256')
|
||||
if repo_key_sig:
|
||||
if jar_sigkey != repo_key_sig:
|
||||
raise FDroidException("Signature key fingerprint of file '{}' does not match repo_key_sha256 in config.py (found fingerprint: '{}')".format(jar_file, jar_sigkey))
|
||||
else:
|
||||
logging.warning("repo_key_sha256 not in config.py, setting it to the signature key fingerprint of '{}'".format(jar_file))
|
||||
config['repo_key_sha256'] = jar_sigkey
|
||||
write_to_config(config, 'repo_key_sha256')
|
||||
|
||||
with zipfile.ZipFile(jar_file, 'r') as f:
|
||||
return json.loads(str(f.read('publishsigkeys.json'), 'utf-8'))
|
||||
|
||||
|
||||
def write_to_config(thisconfig, key, value=None, config_file=None):
|
||||
'''write a key/value to the local config.py
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue