do not crash on some very rare logging

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 6 
src/main/res/values/strings.xml                                          | 1 
2 files changed, 6 insertions(+), 1 deletion(-)

Detailed changes

src/main/java/eu/siacs/conversations/services/XmppConnectionService.java 🔗

@@ -1275,7 +1275,7 @@ public class XmppConnectionService extends Service {
 						if (message.fixCounterpart()) {
 							conversation.startOtrSession(message.getCounterpart().getResourcepart(), true);
 						} else {
-							Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not fix counterpart for OTR message to contact "+message.getContact().getJid());
+							Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not fix counterpart for OTR message to contact "+message.getCounterpart());
 							break;
 						}
 					} else {
@@ -1838,6 +1838,10 @@ public class XmppConnectionService extends Service {
 				try {
 					X509Certificate[] chain = KeyChain.getCertificateChain(XmppConnectionService.this, alias);
 					Pair<Jid, String> info = CryptoHelper.extractJidAndName(chain[0]);
+					if (info == null) {
+						callback.informUser(R.string.certificate_does_not_contain_jid);
+						return;
+					}
 					if (findAccountByJid(info.first) == null) {
 						Account account = new Account(info.first, "");
 						account.setPrivateKeyAlias(alias);

src/main/res/values/strings.xml 🔗

@@ -760,4 +760,5 @@
 	<string name="pref_validate_hostname">Validate hostname with DNSSEC</string>
 	<string name="pref_validate_hostname_summary">Server certificates that contain the validated hostname are considered verified</string>
 	<string name="network_is_unreachable">Network is unreachable</string>
+    <string name="certificate_does_not_contain_jid">Certificate does not contain a Jabber ID</string>
 </resources>