Ich versuche, meine Android-Apps mit der neuen Android-Richtlinie für sichere Apps per requirement and instructions konform zu machen.So reparieren Sie Apps, die eine unsichere Implementierung von TrustManager enthalten
1) Ich habe SSL und https zunächst auf die URLs in meiner app 2) Dann begann ich die Klasse HttpsURLConnection statt HttpURLConnection mit
Hier ein Beispiel für Remote-Aufruf ist, die ich benutze:
public void sendFeedback(String name , String email , String password)
{
String[] params = new String[] { "https://www.problemio.com/auth/create_profile_mobile.php", name , email , password };
DownloadWebPageTask task = new DownloadWebPageTask();
task.execute(params);
}
public class DownloadWebPageTask extends AsyncTask<String, Void, String>
{
private boolean connectionError = false;
@Override
protected void onPreExecute()
{
dialog = new Dialog(CreateProfileActivity.this);
dialog.setContentView(R.layout.please_wait);
dialog.setTitle("Creating Profile");
TextView text = (TextView) dialog.findViewById(R.id.please_wait_text);
text.setText("Please wait while your profile is created... ");
dialog.show();
}
@Override
protected String doInBackground(String... theParams)
{
String myUrl = theParams[0];
final String name = theParams[1];
final String email = theParams[2];
final String password = theParams[3];
String charset = "UTF-8";
String response = null;
try
{
String query = String.format("name=%s&email=%s&password=%s",
URLEncoder.encode(name, charset),
URLEncoder.encode(email, charset),
URLEncoder.encode(password, charset));
final URL url = new URL(myUrl + "?" + query);
final HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.connect();
final InputStream is = conn.getInputStream();
final byte[] buffer = new byte[8196];
int readCount;
final StringBuilder builder = new StringBuilder();
while ((readCount = is.read(buffer)) > -1)
{
builder.append(new String(buffer, 0, readCount));
}
response = builder.toString();
}
catch (Exception e)
{
connectionError = true;
}
return response;
}
@Override
protected void onPostExecute(String result)
{
// Some code
// Make an intent to go to the home screen
Intent myIntent = new Intent(CreateProfileActivity.this, MainActivity.class);
CreateProfileActivity.this.startActivity(myIntent);
}
}
}
Aber es hat das Warnzeichen auf meiner Entwicklerkonsole nicht entfernt. Irgendeine Idee, was ich falsch mache und wie man das repariert?
Warum haben Sie überhaupt einen 'X509TrustManager'? Was ist dein Szenario, in dem du denkst, dass du eins brauchst? https://commonsware.com/blog/2016/02/22/about-x509trustmanager-emails.html – CommonsWare
@CommonsWare Ich las auf dieser Seite, dass dies für sie gelöst ... persönlich habe ich wenig Verständnis dafür http: // stackoverflow.com/questions/35530558/how-to-fix-unsafe-implementation-of-x509trustmanager-in-android-app – Genadinik
Das ist nett, aber es beantwortet meine Frage nicht. Warum haben Sie überhaupt einen 'X509TrustManager'? Wenn Sie noch keine Nachricht erhalten haben und diese Nachricht vom Play Store erhalten haben, stammt Ihr Problem wahrscheinlich von [einer Drittanbieter-Bibliothek] (https://stackoverflow.com/questions/35490107/you-are-using-an -unsafe-Implementierung-von-x509trustmanager/35490317 # 35490317). Wenn Sie selbst einen 'X509TrustManager' hatten, bevor Sie diese Nachricht erhalten ... warum? – CommonsWare