Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-20431]: Remove NonValidatingTrustManager. #7772

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void setAutoRedirect(boolean value)
@Kroll.getProperty @Kroll.method
public boolean getValidatesSecureCertificate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a deprecation notice so that we can remove it in 6.0

{
return client.validatesSecureCertificate();
return true;
}

@Kroll.setProperty @Kroll.method
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import ti.modules.titanium.network.httpurlconnection.HttpUrlConnectionUtils;
import ti.modules.titanium.network.httpurlconnection.JsonBody;
import ti.modules.titanium.network.httpurlconnection.NameValuePair;
import ti.modules.titanium.network.httpurlconnection.NullHostNameVerifier;
import ti.modules.titanium.network.httpurlconnection.StringBody;
import ti.modules.titanium.network.httpurlconnection.StringEntity;
import ti.modules.titanium.network.httpurlconnection.FileBody;
Expand Down Expand Up @@ -401,20 +400,6 @@ public int getReadyState()
return readyState;
}

public boolean validatesSecureCertificate()
{
if (proxy.hasProperty("validatesSecureCertificate")) {
return TiConvert.toBoolean(proxy.getProperty("validatesSecureCertificate"));

} else {
if (TiApplication.getInstance().getDeployType().equals(
TiApplication.DEPLOY_TYPE_PRODUCTION)) {
return true;
}
}
return false;
}

/*
public void addAuthFactory(String scheme, AuthSchemeFactory theFactory)
{
Expand Down Expand Up @@ -890,7 +875,7 @@ private int addTitaniumFileAsPostData(String name, Object value)
return 0;
}

private void setUpSSL(boolean validating, HttpsURLConnection securedConnection)
private void setUpSSL(HttpsURLConnection securedConnection)
{
SSLSocketFactory sslSocketFactory = null;

Expand Down Expand Up @@ -928,15 +913,7 @@ private void setUpSSL(boolean validating, HttpsURLConnection securedConnection)
Log.e(TAG, "Error creating SSLSocketFactory: " + e.getMessage());
sslSocketFactory = null;
}
} else if (!validating) {
TrustManager trustManagerArray[] = new TrustManager[] { new NonValidatingTrustManager() };
try {
sslSocketFactory = new TiSocketFactory(null, trustManagerArray, tlsVersion);
} catch(Exception e) {
Log.e(TAG, "Error creating SSLSocketFactory: " + e.getMessage());
sslSocketFactory = null;
}
} else {
} else {
try {
sslSocketFactory = new TiSocketFactory(null, null, tlsVersion);
} catch(Exception e) {
Expand All @@ -948,12 +925,6 @@ private void setUpSSL(boolean validating, HttpsURLConnection securedConnection)

if (sslSocketFactory != null) {
securedConnection.setSSLSocketFactory(sslSocketFactory);
} else if (!validating) {
securedConnection.setSSLSocketFactory(new NonValidatingSSLSocketFactory());
}

if (!validating) {
securedConnection.setHostnameVerifier(new NullHostNameVerifier());
}
// Fortunately, HttpsURLConnection supports SNI since Android 2.3.
// We don't have to handle SNI explicitly
Expand Down Expand Up @@ -1119,7 +1090,7 @@ public void run()

if (client instanceof HttpsURLConnection) {
HttpsURLConnection securedConnection = (HttpsURLConnection) client;
setUpSSL(validatesSecureCertificate(), securedConnection);
setUpSSL(securedConnection);
}

if (timeout != -1) {
Expand Down