diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java index 26f4da4e5..76bdde3c7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java @@ -397,10 +397,12 @@ public class HkpKeyserver extends Keyserver { .post(body) .build(); - Response response = new OkHttpClient().setProxy(proxy).newCall(request).execute(); + Response response = getClient(url, proxy).newCall(request).execute(); Log.d(Constants.TAG, "response code: " + response.code()); Log.d(Constants.TAG, "answer: " + response.body().string()); + + tempIpTest(proxy); } catch (IOException e) { Log.e(Constants.TAG, "IOException", e); throw new AddKeyException(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java index e39a3a0bf..d50843ef1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java @@ -61,6 +61,7 @@ import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; +import org.sufficientlysecure.keychain.util.orbot.OrbotHelper; import java.util.ArrayList; @@ -90,11 +91,14 @@ public class CertifyKeyFragment private static final int INDEX_IS_REVOKED = 4; private MultiUserIdsAdapter mUserIdsAdapter; + private Preferences.ProxyPrefs mProxyPrefs; @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + mProxyPrefs = Preferences.getPreferences(getActivity()).getProxyPrefs(); + mPubMasterKeyIds = getActivity().getIntent().getLongArrayExtra(CertifyKeyActivity.EXTRA_KEY_IDS); if (mPubMasterKeyIds == null) { Log.e(Constants.TAG, "List of key ids to certify missing!"); @@ -171,7 +175,25 @@ public class CertifyKeyFragment Notify.create(getActivity(), getString(R.string.select_key_to_certify), Notify.Style.ERROR).show(); } else { - cryptoOperation(); + + if (mUploadKeyCheckbox.isChecked() && mProxyPrefs.torEnabled) { + Handler ignoreTorHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + mProxyPrefs = new Preferences.ProxyPrefs(false, false, null, -1, null); + cryptoOperation(); + } + }; + if (!OrbotHelper.isOrbotInstalled(getActivity())) { + OrbotHelper.getInstallDialogFragmentWithThirdButton(new Messenger(ignoreTorHandler), + R.string.orbot_install_dialog_ignore_tor).show(getActivity().getSupportFragmentManager(), "installOrbot"); + } else if (!OrbotHelper.isOrbotRunning()) { + OrbotHelper.getOrbotStartDialogFragment(new Messenger(ignoreTorHandler), + R.string.orbot_install_dialog_ignore_tor).show(getActivity().getSupportFragmentManager(), "startOrbot"); + } else { + cryptoOperation(); + } + } } } });