Disable conscrypt in login page
This commit is contained in:
parent
489f4a3a1c
commit
7fbafa5ae4
|
@ -7,8 +7,8 @@ android {
|
|||
applicationId "fr.gouv.etalab.mastodon"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
versionCode 241
|
||||
versionName "1.73.0"
|
||||
versionCode 242
|
||||
versionName "1.74.0-beta-1"
|
||||
multiDexEnabled true
|
||||
}
|
||||
dexOptions {
|
||||
|
@ -51,7 +51,7 @@ allprojects {
|
|||
}
|
||||
ext.supportLibraryVersion = '28.0.0'
|
||||
ext.glideLibraryVersion = '4.8.0'
|
||||
ext.conscryptLibraryVersion = '1.3.0'
|
||||
ext.conscryptLibraryVersion = '2.0.0'
|
||||
ext.evernoteLibraryVersion = '1.2.6'
|
||||
ext.gsonLibraryVersion = '2.8.2'
|
||||
ext.guavaLibraryVersion = '24.1-android'
|
||||
|
|
|
@ -44,7 +44,6 @@ import android.widget.AdapterView;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -736,11 +735,12 @@ public class LoginActivity extends BaseActivity {
|
|||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main_login, menu);
|
||||
CheckBox checkBox= (CheckBox) menu.findItem(R.id.action_custom_tabs).getActionView();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
|
||||
checkBox.setChecked(!embedded_browser);
|
||||
return true;
|
||||
menu.findItem(R.id.action_custom_tabs).setChecked(!embedded_browser);
|
||||
boolean security_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
menu.findItem(R.id.action_provider).setChecked(security_provider);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -767,6 +767,13 @@ public class LoginActivity extends BaseActivity {
|
|||
editor.putBoolean(Helper.SET_EMBEDDED_BROWSER, !item.isChecked());
|
||||
editor.apply();
|
||||
return false;
|
||||
}else if(id == R.id.action_provider){
|
||||
item.setChecked(!item.isChecked());
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_SECURITY_PROVIDER, item.isChecked());
|
||||
editor.apply();
|
||||
return false;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
|
|
@ -46,9 +46,12 @@ import fr.gouv.etalab.mastodon.jobs.NotificationsSyncJob;
|
|||
public class MainApplication extends MultiDexApplication {
|
||||
|
||||
|
||||
private static MainApplication app;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
//System.setProperty("java.net.preferIPv4Stack" , "true");
|
||||
JobManager.create(this).addJobCreator(new ApplicationJob());
|
||||
NotificationsSyncJob.schedule(false);
|
||||
|
@ -71,7 +74,7 @@ public class MainApplication extends MultiDexApplication {
|
|||
SUPPORTED_LOCALES.add(Locale.getDefault());
|
||||
}
|
||||
LocaleChanger.initialize(getApplicationContext(), SUPPORTED_LOCALES);
|
||||
}catch (Exception ignored){ignored.printStackTrace();}
|
||||
}catch (Exception ignored){}
|
||||
//Initialize upload service
|
||||
UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;
|
||||
Toasty.Config.getInstance()
|
||||
|
@ -85,10 +88,15 @@ public class MainApplication extends MultiDexApplication {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base)
|
||||
{
|
||||
super.attachBaseContext(base);
|
||||
MultiDex.install(MainApplication.this);
|
||||
}
|
||||
|
||||
public static MainApplication getApp(){
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package fr.gouv.etalab.mastodon.client;
|
||||
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
|
@ -12,6 +14,9 @@ import javax.net.ssl.SSLEngine;
|
|||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.MainApplication;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 29/08/2017.
|
||||
*
|
||||
|
@ -78,8 +83,16 @@ public class TLSSocketFactory extends SSLSocketFactory {
|
|||
}
|
||||
|
||||
private Socket enableTLSOnSocket(Socket socket) {
|
||||
if(socket != null && (socket instanceof SSLSocket)) {
|
||||
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
|
||||
if((socket instanceof SSLSocket)) {
|
||||
boolean security_provider = false;
|
||||
try {
|
||||
SharedPreferences sharedpreferences = MainApplication.getApp().getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
security_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
}catch (Exception ignored){}
|
||||
if( security_provider)
|
||||
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2", "TLSv1.3"});
|
||||
else
|
||||
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
|
|
|
@ -223,6 +223,19 @@ public class SettingsFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
boolean patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
final CheckBox set_security_provider = rootView.findViewById(R.id.set_security_provider);
|
||||
set_security_provider.setChecked(patch_provider);
|
||||
|
||||
set_security_provider.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_SECURITY_PROVIDER, set_security_provider.isChecked());
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
boolean display_card = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CARD, false);
|
||||
|
||||
|
|
|
@ -158,6 +158,7 @@ import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
|
|||
import fr.gouv.etalab.mastodon.activities.HashTagActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.LoginActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.MainApplication;
|
||||
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.WebviewActivity;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask;
|
||||
|
@ -368,6 +369,7 @@ public class Helper {
|
|||
public static final String SET_TRUNCATE_TOOTS_SIZE = "set_truncate_toots_size";
|
||||
public static final String SET_ART_WITH_NSFW = "set_art_with_nsfw";
|
||||
public static final String SET_OPTIMIZE_LOADING = "set_optimize_loading";
|
||||
public static final String SET_SECURITY_PROVIDER = "set_security_provider";
|
||||
//End points
|
||||
public static final String EP_AUTHORIZE = "/oauth/authorize";
|
||||
|
||||
|
@ -2947,9 +2949,17 @@ public class Helper {
|
|||
|
||||
|
||||
public static void installProvider(){
|
||||
|
||||
boolean patch_provider = true;
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(),1);
|
||||
Context ctx = MainApplication.getApp();
|
||||
SharedPreferences sharedpreferences = ctx.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
}catch (Exception ignored){}
|
||||
if( patch_provider)
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(),1);
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -479,7 +479,13 @@
|
|||
android:text="@string/set_optimize_loading"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_security_provider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||
android:text="@string/set_security_provider"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -484,6 +484,13 @@
|
|||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_security_provider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||
android:text="@string/set_security_provider"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- TRUNCATE LONG TOOTS -->
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
|
|
|
@ -17,4 +17,8 @@
|
|||
android:title="@string/custom_tabs"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
android:checkable="true"/>
|
||||
<item android:id="@+id/action_provider"
|
||||
android:title="@string/set_security_provider"
|
||||
app:actionViewClass="android.widget.CheckBox"
|
||||
android:checkable="true"/>
|
||||
</menu>
|
||||
|
|
|
@ -878,6 +878,7 @@
|
|||
<string name="set_compact">Compact</string>
|
||||
<string name="set_console">Console</string>
|
||||
<string name="set_mode">Set display mode</string>
|
||||
<string name="set_security_provider">Patch the Security Provider</string>
|
||||
<!-- end languages -->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue