From: Tobias Brunner Date: Fri, 27 Mar 2020 10:39:02 +0000 (+0100) Subject: android: Query user if no password is configured X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=928e606de5abd06ea684ec8b20006061ff9c4c40;p=thirdparty%2Fstrongswan.git android: Query user if no password is configured --- diff --git a/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_creds.c b/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_creds.c index 5421dcae08..63e97e155c 100644 --- a/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_creds.c +++ b/src/frontends/android/app/src/main/jni/libandroidbridge/backend/android_creds.c @@ -251,8 +251,29 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*, private_android_creds_t *this, shared_key_type_t type, identification_t *me, identification_t *other) { - return this->creds->set.create_shared_enumerator(&this->creds->set, - type, me, other); + enumerator_t *enumerator; + shared_key_t *shared = NULL; + char *pwd; + + enumerator = this->creds->set.create_shared_enumerator(&this->creds->set, + type, me, other); + if (enumerator->enumerate(enumerator, &shared, NULL, NULL)) + { + shared = shared->get_ref(shared); + } + else + { + pwd = charonservice->get_password(charonservice); + if (pwd) + { + shared = shared_key_create(type, chunk_clone(chunk_from_str(pwd))); + free(pwd); + } + } + enumerator->destroy(enumerator); + + return shared ? enumerator_create_single(shared, (void*)shared->destroy) + : enumerator_create_empty(); } METHOD(android_creds_t, load_user_certificate, certificate_t*,