Getting Let's encrypt cerificate to work with android api < 20 - android

I have a node server which uses Let's Encrypt CA and it's hosted on zeit.now.
The client is developed using react-native.
I try to connect to it using websockets.
On iOS and newer Android versions (API > 20) it connects successfully.
When running on older Android versions (both on simulator and actual devices) it never connects.
I have tried to connect using older Android version to a server that's not using Let's encrypt CA (but IS using ssl from other provider - hosted on heroku), and it also connects successfully.
So I believe there is something wrong with older Android versions and Let's encrypt certificate.
Could someone help? I have lost 5 days researching this problem and I don't know a lot about JAVA.
EDIT:
I try to connect using websocket
ws.onerror = (e) => {
// an error occurred
console.log(e.message);
};
this logs:
Connection closed by peer
and this method:
ws.onclose = (e) => {
// connection closed
console.log(e.code, e.reason);
};
logs:
undefined, undefined

I fixed it! See this comment.
Basically I needed to install the latest security fixes that are bundled with Google Play Services

I fixed this by adding the following dependency to Gradle:
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
and then calling
public void onCreate() {
super.onCreate();
try {
ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {
// Don't forget exception handling!
} catch (GooglePlayServicesNotAvailableException e) {
// Do something clever
}
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}

Related

Not able to apply Policy of Android Enterprise

I am creating an app with the use of Android Enterprise.
For that, I added dependencies in the build.gradle file.
implementation 'com.google.apis:google-api-services-androidmanagement:v1-rev84-1.25.0'
I am trying to disable uninstalling application using below code from here
try{
Policy policy = new Policy();
policy.setUninstallAppsDisabled(true);
} catch (Exception e) {
e.printStackTrace();
}
But above code is not working. No any Exception or Warning arise
What I am missing? Not able to found proper documentation that how to use Enterprise Management API.
Using the client library of the Android Management API from an Android app is not enough the manage the device the app is running on. You need to first set up the device as managed. For that you can follow the instructions in the quickstart guide.

How to configure a Android Multi Module APP to work with IBM Mobile Foudation Platfom 8.0's AppAuthenticity

We had a Android app that had work fine with IBM Mobile Foudation Platform 8.0' AppAuthenticity. So we had to split the app into multiple android modules, and AppAuthenticity has not work since.
When trying to login with AppAuthenticity enabled there is no response, ie the success or error callbacks are never fired.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/application-authenticity/
IBM MFP Server Version: 8.0.2019022810.
IBM MFP Android SDK Version: 8.0.+
Gradle build tool : 3.1.1
Gradle 4.4
The problem happens with debug and release apks.
Log.d("TAG", "loginMobileFirst init"); // This appears in logcat
String securityCheckName = CaixaSecurityCheckChallengeHandler.SECURITY_CHECK_NAME;
WLAuthorizationManager.getInstance()
.login(securityCheckName, this.getCredencial(),
new WLLoginResponseListener() {
#Override
public void onSuccess() {
Log.d(TAG, "loginMobileFirst Success"); // This never appears in logcat
setLogged(true);
callBack.onSuccess(null);
}
#Override
public void onFailure(WLFailResponse wlFailResponse) {
Log.d(TAG, "loginMobileFirst Failure"); // This never appears in logcat
Log.d(TAG, "Erro no login: " + wlFailResponse.getErrorMsg());
callBack.onError(context.getString(R.string.api_error_sistema_indisponivel));
}
});
}
MobileFirst does not yet support app modules of Android. Please create a single apk for your app until this is supported.
Please open a request for enhancement at https://www.ibm.com/developerworks/rfe/execute?use_case=changeRequestLanding&BRAND_ID=0&PROD_ID=702&x=17&y=6
The problem was solved deleting the directory app/src/main/jniLibs. I believe that directory was included in a old version of IBM MFP (7.1)
Thank you, Folks!

I can't connect my Android App with neo4j database

I'm programming an app in Android but I canĀ“t connect it to a local neo4j database.
In the gradle I've put this dependencies:
compile 'org.neo4j.driver:neo4j-java-driver:1.4.1'
compile 'org.neo4j:neo4j-jdbc:3.1.0'
The connection code is the following:
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
import static org.neo4j.driver.v1.Values.parameters;
public class ConsultasBD {
#TargetApi(Build.VERSION_CODES.KITKAT)
public static boolean consultaLogin(String u, String p) {
try {
// Connect
Driver driver = GraphDatabase.driver( "bolt://192.168.0.39:7474");
Session session = driver.session();
// Querying
StatementResult result = session.run( "MATCH (a:Person {usr: {name}, Pass: {pass}})",
parameters( u, p ) );
while ( result.hasNext() )
{
System.out.println("OK");
}
session.close();
driver.close();
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
}
But when I run it, I get this exception:
java.lang.NoClassDefFoundError:
Failed resolution of: Ljava/net/StandardSocketOptions;
And I don't know how can I fix it.
Can anyone explain me how can I connect my app with neo4j?
Thank you very much.
Miguel
StandardSocketOptions was only added to Android in API level 24 (Nougat). So, unless you have a device with API level 24 or higher, you will get that exception.
However, even if you do run your app on such a device, there may be other needed classes that are missing. This is because the neo4j Java libraries do not attempt to target the Android environment (which only supports part of the standard Java libraries). So, this kind of problem is to be expected. Android apps should use the neo4j HTTP API instead.

Xamarin.android Default FirebaseApp is not initialized in this process

I face issue with get token from firebase (push notification)
Default FirebaseApp is not initialized in this process com.ready_apps.Nebka.Business. Make sure to call FirebaseApp.initializeApp(Context) first.
even I called FirebaseApp.InitializeApp(this); in many places
MyApplication (that extend Application) , in onCreate of Activity where I call FirebaseInstanceId.Instance?.Token;
Edit: This bug has been fixed in Xamarin.Firebase version 57.1104.0-beta1.
This error seems to be present in the newer versions of Firebase for Xamarin. I am also experiencing this error as of today, using the latest stable version 42.1021.1. (The error is also present in the latest beta build).
I found that a bug report has been filed for the issue here.
As mentioned in the bug report, deleting both the /obj and /bin folders in your Android project, and/or cleaning the project in Visual Studio should fix the problem temporarily until you update any resource that would change the Resource.Designer.cs file.
Downgrading to an older version of Firebase and Google Play Services is also possible before a permanent solution is available. I did not experience this error on Firebase and Google Play Services version 32.961.0, for example.
Just Clean the solution once and run the app again.
This bug is already reported to Xamarin.
https://bugzilla.xamarin.com/show_bug.cgi?id=56108
This solution is provided in their comment thread, it might get fixed in the newer release of xamarin NuGet package.
I didnt fix it but I find walkaround this issue in debug mode only
I called this method onCreate() in activit I need to request the token
FirebaseInstanceId.Instance?.Token
here is the method
private void ConfigureFireBase()
{
#if DEBUG
try
{
Task.Run(() =>
{
var instanceId = FirebaseInstanceId.Instance;
instanceId?.DeleteInstanceId();
//Log.Debug("TAG", "{0} {1}", instanceId?.Token?.ToString(), instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
});
// For debug mode only - will accept the HTTPS certificate of Test/Dev server, as the HTTPS certificate is invalid /not trusted
ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
}catch (Exception e)
{
Log.Debug("TAG", e.Message);
}
#endif
}

com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Handshake failed

Using volley for basic network operations,getting no connection handshake error when adding the project as an module.
While the module works fine in some another project.
On R&D, added retrypolicy but no use still getting the same error.
Here is my code.
https://gist.github.com/fizzysoftware/a895bc2cbd1ad9a048277859f3f23963
It could be one of these two cases:
You try to connect to an HTTP url but it's actually an HTTPS url, or
You try to connect to an HTTPS page but the certificate is not valid.
These are at least the cases I've encountered so far...
Changing the url from Https to Http will work.
In my project also same issues are faced. In Marshmallow its work suffecfully. But in Kitkat version it raised the issue
"com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Handshake failed"
For Handling this I used google's auth dependencies. Kindly add the following dependency in your Gradle
compile 'com.google.android.gms:play-services-auth:11.0.2'
And Implement the method for Installing Security Provider in Lower versions, If instalation's required
private void updateAndroidSecurityProvider(Activity callingActivity) {
try {
ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {
// Thrown when Google Play Services is not installed, up-to-date, or enabled
// Show dialog to allow users to install, update, or otherwise enable Google Play services.
GooglePlayServicesUtil.getErrorDialog(e.getConnectionStatusCode(), callingActivity, 0);
} catch (GooglePlayServicesNotAvailableException e) {
Log.e("SecurityException", "Google Play Services not available.");
}
}
Then call the method in your activity, before making network operations.

Categories

Resources