Remove subkeys.pgp.net keyserver, often down and no hkps

This commit is contained in:
Dominik Schürmann 2014-08-15 10:19:46 +02:00
parent bc76941bc1
commit cf450d24fb
2 changed files with 21 additions and 8 deletions

View File

@ -72,7 +72,7 @@ public final class Constants {
public static final class Defaults { public static final class Defaults {
public static final String KEY_SERVERS = "hkps://hkps.pool.sks-keyservers.net, subkeys.pgp.net, hkps://pgp.mit.edu"; public static final String KEY_SERVERS = "hkps://hkps.pool.sks-keyservers.net, subkeys.pgp.net, hkps://pgp.mit.edu";
public static final int KEY_SERVERS_VERSION = 2; public static final int KEY_SERVERS_VERSION = 3;
} }
public static final class DrawerItems { public static final class DrawerItems {

View File

@ -26,6 +26,10 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
import org.spongycastle.openpgp.PGPEncryptedData; import org.spongycastle.openpgp.PGPEncryptedData;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Vector; import java.util.Vector;
/** /**
@ -175,15 +179,24 @@ public class Preferences {
// migrate keyserver to hkps // migrate keyserver to hkps
if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) != if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) !=
Constants.Defaults.KEY_SERVERS_VERSION) { Constants.Defaults.KEY_SERVERS_VERSION) {
String[] servers = getKeyServers(); String[] serversArray = getKeyServers();
for (int i = 0; i < servers.length; i++) { ArrayList<String> servers = new ArrayList<String>(Arrays.asList(serversArray));
if (servers[i].equals("pool.sks-keyservers.net")) { ListIterator<String> it = servers.listIterator();
servers[i] = "hkps://hkps.pool.sks-keyservers.net"; while (it.hasNext()) {
} else if (servers[i].equals("pgp.mit.edu")) { String server = it.next();
servers[i] = "hkps://pgp.mit.edu"; if (server.equals("pool.sks-keyservers.net")) {
// use HKPS!
it.set("hkps://hkps.pool.sks-keyservers.net");
} else if (server.equals("pgp.mit.edu")) {
// use HKPS!
it.set("hkps://pgp.mit.edu");
} else if (server.equals("subkeys.pgp.net")) {
// remove, because often down and no HKPS!
it.remove();
} }
} }
setKeyServers(servers); setKeyServers(servers.toArray(new String[servers.size()]));
mSharedPreferences.edit() mSharedPreferences.edit()
.putInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, Constants.Defaults.KEY_SERVERS_VERSION) .putInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, Constants.Defaults.KEY_SERVERS_VERSION)
.commit(); .commit();