Merge branch '0.96-swap-fixes' into 'master'

0.96 swap fixes

This fixes the swap issues that I could find, except for #391. @mvdan feel free to beat @pserwylo to this, I just assigned it to him because its swap.

See merge request !127
This commit is contained in:
Daniel Martí 2015-08-27 16:35:13 +00:00
commit cbaa8676fc
6 changed files with 18 additions and 15 deletions

View File

@ -52,10 +52,6 @@
<EditTextPreference
android:key="localRepoName"
android:title="@string/local_repo_name" />
<CheckBoxPreference
android:defaultValue="false"
android:key="localRepoHttps"
android:title="@string/local_repo_https" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/proxy" >
<CheckBoxPreference

View File

@ -152,7 +152,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
}
public boolean isLocalRepoHttpsEnabled() {
return preferences.getBoolean(PREF_LOCAL_REPO_HTTPS, DEFAULT_LOCAL_REPO_HTTPS);
return false; // disabled until it works well
}
private String getDefaultLocalRepoName() {

View File

@ -339,6 +339,8 @@ public final class Utils {
}
public static String calcFingerprint(Certificate cert) {
if (cert == null)
return null;
try {
return calcFingerprint(cert.getEncoded());
} catch (CertificateEncodingException e) {
@ -347,6 +349,8 @@ public final class Utils {
}
public static String calcFingerprint(byte[] key) {
if (key == null)
return null;
String ret = null;
if (key.length < 256) {
Log.e(TAG, "key was shorter than 256 bytes (" + key.length + "), cannot be valid!");

View File

@ -10,6 +10,7 @@ import org.spongycastle.asn1.x500.X500Name;
import org.spongycastle.asn1.x509.GeneralName;
import org.spongycastle.asn1.x509.GeneralNames;
import org.spongycastle.asn1.x509.SubjectPublicKeyInfo;
import org.spongycastle.asn1.x509.Time;
import org.spongycastle.asn1.x509.X509Extension;
import org.spongycastle.cert.X509CertificateHolder;
import org.spongycastle.cert.X509v3CertificateBuilder;
@ -41,6 +42,8 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
@ -291,17 +294,22 @@ public class LocalRepoKeyStore {
SubjectPublicKeyInfo subPubKeyInfo = new SubjectPublicKeyInfo(
ASN1Sequence.getInstance(pubKey.getEncoded()));
Date startDate = new Date(); // now
Date now = new Date(); // now
Calendar c = Calendar.getInstance();
c.setTime(startDate);
/* force it to use a English/Gregorian dates for the cert, hardly anyone
ever looks at the cert metadata anyway, and its very likely that they
understand English/Gregorian dates */
Calendar c = new GregorianCalendar(Locale.ENGLISH);
c.setTime(now);
c.add(Calendar.YEAR, 1);
Date endDate = c.getTime();
Time startTime = new Time(now, Locale.ENGLISH);
Time endTime = new Time(c.getTime(), Locale.ENGLISH);
X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(
subject,
BigInteger.valueOf(rand.nextLong()),
startDate, endDate,
startTime,
endTime,
subject,
subPubKeyInfo);

View File

@ -123,10 +123,6 @@ public class WifiStateChangeService extends Service {
// the fingerprint for the local repo's signing key
LocalRepoKeyStore localRepoKeyStore = LocalRepoKeyStore.get(context);
Certificate localCert = localRepoKeyStore.getCertificate();
// We were not able to generate/get a certificate
if (localCert == null) {
return null;
}
FDroidApp.repo.fingerprint = Utils.calcFingerprint(localCert);
/*

View File

@ -39,7 +39,6 @@ public class PreferencesFragment extends PreferenceFragment
Preferences.PREF_IGN_TOUCH,
Preferences.PREF_LOCAL_REPO_BONJOUR,
Preferences.PREF_LOCAL_REPO_NAME,
Preferences.PREF_LOCAL_REPO_HTTPS,
Preferences.PREF_LANGUAGE,
Preferences.PREF_CACHE_APK,
Preferences.PREF_EXPERT,