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

android build fixed #65

Closed
wants to merge 1 commit into from
Closed

android build fixed #65

wants to merge 1 commit into from

Conversation

andrey-starodubtsev
Copy link
Contributor

build for android cannot establish TLS connection because lines from
patch were dropped in 640849d. Earlier these changes were added in 7ceb5f0.

build for android cannot establish TLS connection because lines from
patch were dropped in 640849d. Earlier these changes were added in 7ceb5f0.
@Flowdalic
Copy link
Member

The code was actually changed in c6594ae,

I assume it doesn't work on Android if there is no custom context specified? Could you describe what happens then? Exception? If so, please show the stacktrace. Thank you.

@andrey-starodubtsev
Copy link
Contributor Author

HEAD version crashes with following stack:

01-19 15:21:21.353   336   336 D ACRA    : Stacktrace: 
01-19 15:21:21.353   336   336 D ACRA    : --- [ Crushed Thread #1 ] ---
01-19 15:21:21.353   336   336 D ACRA    : java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MyActivity}: java.lang.RuntimeException: org.jivesoftware.smack.SmackException: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.access$800(ActivityThread.java:139)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
01-19 15:21:21.353   336   336 D ACRA    :  at android.os.Handler.dispatchMessage(Handler.java:102)
01-19 15:21:21.353   336   336 D ACRA    :  at android.os.Looper.loop(Looper.java:136)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.main(ActivityThread.java:5102)
01-19 15:21:21.353   336   336 D ACRA    :  at java.lang.reflect.Method.invokeNative(Native Method)
01-19 15:21:21.353   336   336 D ACRA    :  at java.lang.reflect.Method.invoke(Method.java:515)
01-19 15:21:21.353   336   336 D ACRA    :  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-19 15:21:21.353   336   336 D ACRA    :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-19 15:21:21.353   336   336 D ACRA    :  at dalvik.system.NativeStart.main(Native Method)
01-19 15:21:21.353   336   336 D ACRA    : Caused by: java.lang.RuntimeException: org.jivesoftware.smack.SmackException: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
01-19 15:21:21.353   336   336 D ACRA    :  at com.example.MyActivity.onCreate(MyActivity.java:414)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.Activity.performCreate(Activity.java:5248)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
01-19 15:21:21.353   336   336 D ACRA    :  ... 11 more
01-19 15:21:21.353   336   336 D ACRA    : Caused by: org.jivesoftware.smack.SmackException: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
01-19 15:21:21.353   336   336 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:997)
01-19 15:21:21.353   336   336 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:924)
01-19 15:21:21.353   336   336 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:939)
01-19 15:21:21.353   336   336 D ACRA    :  at java.lang.Thread.run(Thread.java:841)
01-19 15:21:21.353   336   336 D ACRA    : Caused by: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
01-19 15:21:21.353   336   336 D ACRA    :  at java.security.KeyStore.getInstance(KeyStore.java:119)
01-19 15:21:21.353   336   336 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:697)
01-19 15:21:21.353   336   336 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:145)
01-19 15:21:21.353   336   336 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:990)
01-19 15:21:21.353   336   336 D ACRA    :  ... 3 more
01-19 15:21:21.353   336   336 D ACRA    : Caused by: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
01-19 15:21:21.353   336   336 D ACRA    :  at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
01-19 15:21:21.353   336   336 D ACRA    :  at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
01-19 15:21:21.353   336   336 D ACRA    :  at java.security.KeyStore.getInstance(KeyStore.java:116)
01-19 15:21:21.353   336   336 D ACRA    :  ... 6 more
01-19 15:21:21.353   336   336 D ACRA    : java.lang.RuntimeException: org.jivesoftware.smack.SmackException: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
01-19 15:21:21.353   336   336 D ACRA    :  at com.example.MyActivity.onCreate(MyActivity.java:414)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.Activity.performCreate(Activity.java:5248)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.access$800(ActivityThread.java:139)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
01-19 15:21:21.353   336   336 D ACRA    :  at android.os.Handler.dispatchMessage(Handler.java:102)
01-19 15:21:21.353   336   336 D ACRA    :  at android.os.Looper.loop(Looper.java:136)
01-19 15:21:21.353   336   336 D ACRA    :  at android.app.ActivityThread.main(ActivityThread.java:5102)
01-19 15:21:21.353   336   336 D ACRA    :  at java.lang.reflect.Method.invokeNative(Native Method)
01-19 15:21:21.353   336   336 D ACRA    :  at java.lang.reflect.Method.invoke(Method.java:515)
01-19 15:21:21.353   336   336 D ACRA    :  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-19 15:21:21.353   336   336 D ACRA    :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-19 15:21:21.353   336   336 D ACRA    :  at dalvik.system.NativeStart.main(Native Method)
01-19 15:21:21.353   336   336 D ACRA    : Caused by: org.jives

when I try to create XMPPTCPConnection.

According http://stackoverflow.com/questions/11712671/smack-no-response-from-server-not-sure-why-am-i-getting-this-error, 'jks' keystore type is absent on Android, but even if you create your connection like that:

try {
  System.setProperty( "ssl.TrustManagerFactory.algorithm", javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm());
  XMPPTCPConnectionConfiguration configuration = XMPPTCPConnectionConfiguration.builder()
      .setUsernameAndPassword("user", "password")
      .setXmppDomain(JidCreate.domainBareFrom("example.com"))
      .setKeystoreType("BKS").build();
  mConnection = new XMPPTCPConnection(configuration);
} catch (XmppStringprepException e) {
  e.printStackTrace();
  throw new RuntimeException(e);
}

, it still fails with following stack:

01-19 15:36:08.437  2918  2918 D ACRA    : Stacktrace: 
01-19 15:36:08.437  2918  2918 D ACRA    : --- [ Crushed Thread #1 ] ---
01-19 15:36:08.437  2918  2918 D ACRA    : java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MyActivity}: java.lang.RuntimeException: org.jivesoftware.smack.SmackException: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.access$800(ActivityThread.java:139)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.os.Handler.dispatchMessage(Handler.java:102)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.os.Looper.loop(Looper.java:136)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.main(ActivityThread.java:5102)
01-19 15:36:08.437  2918  2918 D ACRA    :  at java.lang.reflect.Method.invokeNative(Native Method)
01-19 15:36:08.437  2918  2918 D ACRA    :  at java.lang.reflect.Method.invoke(Method.java:515)
01-19 15:36:08.437  2918  2918 D ACRA    :  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-19 15:36:08.437  2918  2918 D ACRA    :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-19 15:36:08.437  2918  2918 D ACRA    :  at dalvik.system.NativeStart.main(Native Method)
01-19 15:36:08.437  2918  2918 D ACRA    : Caused by: java.lang.RuntimeException: org.jivesoftware.smack.SmackException: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
01-19 15:36:08.437  2918  2918 D ACRA    :  at com.example.MyActivity.onCreate(MyActivity.java:428)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.Activity.performCreate(Activity.java:5248)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
01-19 15:36:08.437  2918  2918 D ACRA    :  ... 11 more
01-19 15:36:08.437  2918  2918 D ACRA    : Caused by: org.jivesoftware.smack.SmackException: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:997)
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:924)
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:939)
01-19 15:36:08.437  2918  2918 D ACRA    :  at java.lang.Thread.run(Thread.java:841)
01-19 15:36:08.437  2918  2918 D ACRA    : Caused by: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
01-19 15:36:08.437  2918  2918 D ACRA    :  at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:77)
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:708)
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:145)
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:990)
01-19 15:36:08.437  2918  2918 D ACRA    :  ... 3 more
01-19 15:36:08.437  2918  2918 D ACRA    : java.lang.RuntimeException: org.jivesoftware.smack.SmackException: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
01-19 15:36:08.437  2918  2918 D ACRA    :  at com.example.MyActivity.onCreate(MyActivity.java:428)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.Activity.performCreate(Activity.java:5248)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.access$800(ActivityThread.java:139)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.os.Handler.dispatchMessage(Handler.java:102)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.os.Looper.loop(Looper.java:136)
01-19 15:36:08.437  2918  2918 D ACRA    :  at android.app.ActivityThread.main(ActivityThread.java:5102)
01-19 15:36:08.437  2918  2918 D ACRA    :  at java.lang.reflect.Method.invokeNative(Native Method)
01-19 15:36:08.437  2918  2918 D ACRA    :  at java.lang.reflect.Method.invoke(Method.java:515)
01-19 15:36:08.437  2918  2918 D ACRA    :  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-19 15:36:08.437  2918  2918 D ACRA    :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-19 15:36:08.437  2918  2918 D ACRA    :  at dalvik.system.NativeStart.main(Native Method)
01-19 15:36:08.437  2918  2918 D ACRA    : Caused by: org.jivesoftware.smack.SmackException: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:997)
01-19 15:36:08.437  2918  2918 D ACRA    :  at org.jivesoftwa

@Flowdalic
Copy link
Member

I've uploaded a new Snapshot of 4.2.0-alpha3 which includes Flowdalic@a9708ef. I think this fixes the issues in a cleaner way then https://github.com/andrey-starodubtsev/Smack/commit/668413e40715b15d6369d65e938122199cbd09f5. Could you test and report back if it works for you?

@andrey-starodubtsev
Copy link
Contributor Author

It works, however I can see complain about NPE in logcat:

01-21 21:00:55.761  1789  1975 W XMPPTCPConnection: Exception
01-21 21:00:55.761  1789  1975 W XMPPTCPConnection: java.lang.NullPointerException: Attempt to invoke interface method 'void javax.security.auth.callback.CallbackHandler.handle(javax.security.auth.callback.Callb ack[])' on a null object reference
01-21 21:00:55.761  1789  1975 W XMPPTCPConnection:   at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:702)
01-21 21:00:55.761  1789  1975 W XMPPTCPConnection:   at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:145)
01-21 21:00:55.761  1789  1975 W XMPPTCPConnection:   at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:997)
01-21 21:00:55.761  1789  1975 W XMPPTCPConnection:   at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:931)
01-21 21:00:55.761  1789  1975 W XMPPTCPConnection:   at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:946)
01-21 21:00:55.761  1789  1975 W XMPPTCPConnection:   at java.lang.Thread.run(Thread.java:818)

And one still have to set "bks" as default keystore type for Android.

@Flowdalic
Copy link
Member

Thanks for the feedback. Much appreciated. I've uploaded a new snapshot with Flowdalic@39dacaf. This should prevent the NPE. Could you test and report back?

@Flowdalic
Copy link
Member

Fixed merged into master. Thanks for reporting the issue.

@Flowdalic Flowdalic closed this Jan 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants