From 7daa46503d3f0cd970fce3769ad1e79c9cecc0ef Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Wed, 12 Sep 2018 06:13:04 +0000
Subject: [PATCH] Don't risk incompatibilities

---
 mod/dfrn_notify.php   | 2 +-
 src/Protocol/DFRN.php | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index 2f76b59b97..8a53ac09b6 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -326,7 +326,7 @@ function dfrn_notify_content(App $a) {
 		$pub_key = trim($importer['cpubkey']);
 		$dplx    = intval($importer['duplex']);
 
-		if (!empty($prv_key) && empty($pub_key)) {
+		if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) {
 			openssl_private_encrypt($hash, $challenge, $prv_key);
 			openssl_private_encrypt($id_str, $encrypted_id, $prv_key);
 		} elseif (strlen($pub_key)) {
diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php
index 3832e38e16..b207c3ca87 100644
--- a/src/Protocol/DFRN.php
+++ b/src/Protocol/DFRN.php
@@ -1280,7 +1280,10 @@ class DFRN
 			}
 		}
 
-		if (empty($contact['prvkey']) && !empty($contact['pubkey'])) {
+		if (($contact['duplex'] && strlen($contact['pubkey']))
+			|| ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
+			|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
+		) {
 			openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
 			openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']);
 		} else {
-- 
2.39.5