put bug report jid in config. include package signature in report

This commit is contained in:
Daniel Gultsch 2016-05-28 11:04:18 +02:00
parent 06bef5de8d
commit ae7543bbfc
3 changed files with 26 additions and 13 deletions

View file

@ -36,6 +36,8 @@ public final class Config {
public static final String LOGTAG = "conversations"; public static final String LOGTAG = "conversations";
public static final String BUG_REPORTS = "bugs@conversations.im";
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
public static final String MAGIC_CREATE_DOMAIN = "conversations.im"; public static final String MAGIC_CREATE_DOMAIN = "conversations.im";

View file

@ -9,6 +9,7 @@ import org.bouncycastle.asn1.x500.style.IETFUtils;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateParsingException; import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
@ -184,9 +185,7 @@ public final class CryptoHelper {
//ignored //ignored
} }
try { try {
MessageDigest md = MessageDigest.getInstance("SHA-1"); information.putString("sha1", getFingerprintCert(certificate.getEncoded()));
byte[] fingerprint = md.digest(certificate.getEncoded());
information.putString("sha1", prettifyFingerprintCert(bytesToHex(fingerprint)));
} catch (Exception e) { } catch (Exception e) {
} }
@ -196,6 +195,12 @@ public final class CryptoHelper {
} }
} }
public static String getFingerprintCert(byte[] input) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] fingerprint = md.digest(input);
return prettifyFingerprintCert(bytesToHex(fingerprint));
}
public static int encryptionTypeToText(int encryption) { public static int encryptionTypeToText(int encryption) {
switch (encryption) { switch (encryption) {
case Message.ENCRYPTION_OTR: case Message.ENCRYPTION_OTR:

View file

@ -8,6 +8,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.util.Log; import android.util.Log;
@ -18,6 +19,8 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
@ -31,6 +34,7 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.jid.Jid;
public class ExceptionHelper { public class ExceptionHelper {
private static SimpleDateFormat DATE_FORMATs = new SimpleDateFormat("yyyy-MM-dd");
public static void init(Context context) { public static void init(Context context) {
if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof ExceptionHandler)) { if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof ExceptionHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler( Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(
@ -43,7 +47,7 @@ public class ExceptionHelper {
final SharedPreferences preferences = PreferenceManager final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(activity); .getDefaultSharedPreferences(activity);
boolean neverSend = preferences.getBoolean("never_send", false); boolean neverSend = preferences.getBoolean("never_send", false);
if (neverSend) { if (neverSend || Config.BUG_REPORTS == null) {
return false; return false;
} }
List<Account> accounts = service.getAccounts(); List<Account> accounts = service.getAccounts();
@ -63,16 +67,18 @@ public class ExceptionHelper {
BufferedReader stacktrace = new BufferedReader(inputStreamReader); BufferedReader stacktrace = new BufferedReader(inputStreamReader);
final StringBuilder report = new StringBuilder(); final StringBuilder report = new StringBuilder();
PackageManager pm = activity.getPackageManager(); PackageManager pm = activity.getPackageManager();
PackageInfo packageInfo = null; PackageInfo packageInfo;
try { try {
packageInfo = pm.getPackageInfo(activity.getPackageName(), 0); packageInfo = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES);
report.append("Version: " + packageInfo.versionName + '\n'); report.append("Version: " + packageInfo.versionName + '\n');
report.append("Last Update: " report.append("Last Update: " + DATE_FORMATs.format(new Date(packageInfo.lastUpdateTime)) + '\n');
+ DateUtils.formatDateTime(activity, Signature[] signatures = packageInfo.signatures;
packageInfo.lastUpdateTime, if (signatures != null && signatures.length >= 1) {
DateUtils.FORMAT_SHOW_TIME report.append("SHA-1: " + CryptoHelper.getFingerprintCert(packageInfo.signatures[0].toByteArray()) + "\n");
| DateUtils.FORMAT_SHOW_DATE) + '\n'); }
} catch (NameNotFoundException e) { report.append('\n');
} catch (Exception e) {
e.printStackTrace();
return false; return false;
} }
String line; String line;
@ -97,7 +103,7 @@ public class ExceptionHelper {
Conversation conversation = null; Conversation conversation = null;
try { try {
conversation = service.findOrCreateConversation(finalAccount, conversation = service.findOrCreateConversation(finalAccount,
Jid.fromString("bugs@siacs.eu"), false); Jid.fromString(Config.BUG_REPORTS), false);
} catch (final InvalidJidException ignored) { } catch (final InvalidJidException ignored) {
} }
Message message = new Message(conversation, report Message message = new Message(conversation, report