chiark / gitweb /
use jarsigner to verify the APK signature is valid
authorHans-Christoph Steiner <hans@eds.org>
Sat, 30 Aug 2014 02:53:21 +0000 (22:53 -0400)
committerCiaran Gultnieks <ciaran@ciarang.com>
Fri, 7 Nov 2014 09:20:04 +0000 (09:20 +0000)
By using jarsigner here, we can get rid of getsig.java, since the rest of
what getsig.java does can easily be handled in python.  This simplifies
installation and deployment, and makes things work better cross-platform.
This also means that the fdroidserver Debian package no longer needs to
Build-Depends: on default-jdk, which makes builds in pbuilder run a lot
faster. :-)

refs #5 https://gitlab.com/fdroid/fdroidserver/issues/5

fdroidserver/update.py

index c4e08fb509ad016f8d6c6e89bcf7eb00b95401a9..e161764d78479ff9e2f5bab11c262eb47f5fe5cd 100644 (file)
@@ -465,6 +465,16 @@ def scan_apks(apps, apkcache, repodir, knownapks):
                     sha.update(t)
                 thisinfo['sha256'] = sha.hexdigest()
 
+            # verify the jar signature is correct
+            args = ['jarsigner', '-verify']
+            if options.verbose:
+                args += ['-verbose', '-certs']
+            args += apkfile
+            p = FDroidPopen(args)
+            if p.returncode != 0:
+                logging.critical(apkfile + " has a bad signature!")
+                sys.exit(1)
+
             # Get the signature (or md5 of, to be precise)...
             getsig_dir = os.path.join(os.path.dirname(__file__), 'getsig')
             if not os.path.exists(getsig_dir + "/getsig.class"):