From 711a1418b6a33be18b4edfaa0536696a15441c70 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 2 Dec 2013 19:54:07 -0500 Subject: [PATCH] make DB.calcFingerprint() return null if pubkey is null Handling it here seems to keep the flow simple. --- src/org/fdroid/fdroid/DB.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 75b27efdc..73236124e 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -465,6 +465,8 @@ public class DB { public static String calcFingerprint(String pubkey) { String ret = null; + if (pubkey == null) + return null; try { // keytool -list -v gives you the SHA-256 fingerprint MessageDigest digest = MessageDigest.getInstance("SHA-256"); @@ -1410,7 +1412,7 @@ public class DB { String calcedFingerprint = DB.calcFingerprint(pubkey); if (fingerprint == null) { fingerprint = calcedFingerprint; - } else { + } else if (calcedFingerprint != null) { fingerprint = fingerprint.toUpperCase(); if (!fingerprint.equals(calcedFingerprint)) { throw new SecurityException("Given fingerprint does not match calculated one! ("