Update Keyservers to use hkps as needed

This commit is contained in:
mar-v-in 2014-06-24 11:26:52 +02:00
parent f039ef81ae
commit 04e64ac84e
3 changed files with 25 additions and 2 deletions

View file

@ -102,10 +102,12 @@ public final class Constants {
public static final String LANGUAGE = "language";
public static final String FORCE_V3_SIGNATURES = "forceV3Signatures";
public static final String KEY_SERVERS = "keyServers";
public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion";
}
public static final class Defaults {
public static final String KEY_SERVERS = "pool.sks-keyservers.net, subkeys.pgp.net, pgp.mit.edu";
public static final String KEY_SERVERS = "hkps://pool.sks-keyservers.net, subkeys.pgp.net, hkps://pgp.mit.edu";
public static final int KEY_SERVERS_VERSION = 2;
}
public static final class DrawerItems {

View file

@ -26,7 +26,7 @@ import android.graphics.drawable.Drawable;
import android.os.Environment;
import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.sufficientlysecure.keychain.helper.ContactHelper;
import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.PRNGFixes;
@ -81,6 +81,9 @@ public class KeychainApplication extends Application {
getApplicationContext().getResources().getColor(R.color.emphasis));
setupAccountAsNeeded(this);
// Update keyserver list as needed
Preferences.getPreferences(this).updateKeyServers();
}
public static void setupAccountAsNeeded(Context context) {

View file

@ -169,4 +169,22 @@ public class Preferences {
editor.putString(Constants.Pref.KEY_SERVERS, rawData);
editor.commit();
}
public void updateKeyServers() {
if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) !=
Constants.Defaults.KEY_SERVERS_VERSION) {
String[] servers = getKeyServers();
for (int i = 0; i < servers.length; i++) {
if (servers[i].equals("pool.sks-keyservers.net")) {
servers[i] = "hkps://hkps.pool.sks-keyservers.net";
} else if (servers[i].equals("pgp.mit.edu")) {
servers[i] = "hkps://pgp.mit.edu";
}
}
setKeyServers(servers);
mSharedPreferences.edit()
.putInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, Constants.Defaults.KEY_SERVERS_VERSION)
.commit();
}
}
}