diff --git a/src/foundation_pEp_jniadapter_AbstractEngine.cc b/src/foundation_pEp_jniadapter_AbstractEngine.cc index beb06ef..b4e038b 100644 --- a/src/foundation_pEp_jniadapter_AbstractEngine.cc +++ b/src/foundation_pEp_jniadapter_AbstractEngine.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include "throw_pEp_exception.hh" #include "jniutils.hh" @@ -95,8 +96,16 @@ PEP_STATUS messageToSend(message *msg) std::lock_guard l(mutex_obj); pEpLog("############### messageToSend() called"); - jobject msg_ = nullptr; + // Passphrase + // When a protocol implementation of the p≡p engine using messageToSend() cannot sign or encrypt with an + // empty passphrase and not with the configured passphrase it is calling messageToSend() with a NULL instead + // of a struct _message object. + if (Adapter::on_sync_thread() && !msg) { + return pEp::PassphraseCache::messageToSend(cache, Adapter::session()); + } + + jobject msg_ = nullptr; assert(messageClass && messageConstructorMethodID && objj && messageToSendMethodID); msg_ = o.env()->NewObject(messageClass, messageConstructorMethodID, (jlong) msg);