powered by Jive Software

Updating Smack to 4.0.0 in Spark

There is a ticket for updating Spark to the latest Smack version SPARK-1567 Actually it started with 3.4.0 and then i have modified it a few times. Smack updates are slow in Spark…

4.0.0 is in RC state, so maybe we should wait a little for it to get a final status. Though we can update and test nightly builds and revert if something brakes (in 3.4.0 there were changes to Workgroups, so maybe it affects Fastpath). 4.0.0 contains security fixes and other improvements.

Changes to Smack API: http://community.igniterealtime.org/docs/DOC-2703

we’ll also need to check for any API’s that have been changed, broke, and/or deprecated in the new version… Flow has been doing some very heavy work it seems. It may or may not be a simple “drag n drop” the new lib into spark.

I would be happy to assist. There are sure some things missing in the Smack 4.0 upgrade guide, that we should add.

I think we should create a ‘smack4’ branch in sparks git repo and see if we can unbundle smack and use a maven dependency instead.

hmm, well if we’re going to replace one binary dependency with another dependency of maven… perhaps it’s just time to go full maven? (i suppose upgrading to new smack lib is a different project than restructoring everything to use maven though)

pardon my ignorance on maven, but how does it handle binaries that are modified in source? some of the jar libs in spark have been compiled from source after minor changes, such as jtattoo’s checkbox sizes. does it mean these binaries would have to stay in the project source?

So. 4.0.0 is out. I think it is time to try update Smack in Spark to 4.0.0 and see if it breaks anything

I’ve started a smack4 branch for Spark a while ago: https://github.com/Flowdalic/Spark/tree/smack4

Since Smack 4 includes some API changes, switching from Smack 3 to Smack 4 is not trivial. If somebody wants to finish my smack4 branch in Spark, then he’s welcome to do so.

Ah, so we can’t just drop Smack 4 in and hope it works? Or can we swap the lib and test what is not working correctly (to help evaluate how much work needs to be done). Or it won’t even run this way?

No, there are also code changes required.

As @Flow’s work is two years old, I restarted the effort to migrate Spark from Smack 3 to Smack 4. I’m close to getting it in a compilable state. Help is appreciated: GitHub - guusdk/Spark at Smack-4

Will give it a shot later. This thread and a ticket got so old We even had a lesser ticket to just bump to 3.4.0 and couldn’t figure out with @speedy how to make Fastpath work with a minor Smack upgrade (it had divided smackx into smackx and smack-worgroups and that broke Fastpath, though i’m sure the fix should be simple).

I know that you don’t use Eclipse (or Windows ), but i get this when trying to build your Smack 4 branch:

<>

Yeah, I know. I said that I was getting close to be able to compile - but I’m not there yet. Some of those exceptions have already been fixed, by the way.

Yep, getting 5 errors instead of 21 now

This commit marks the state of the code that I was able to compile and execute. I successfully authenticated to igniterealtime.org, joined the open_chat room and left a message.

SMACK4: Settled Smack dependencies. · guusdk/Spark@af4acf1 · GitHub

There are a lot of exceptions being thrown left and right, but hey:

  1. Make it run.
  2. Make it right.
    One down.

I’m able to build now, but i can’t login to our server or my local test server.

May 01, 2016 10:09:31 AM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener
WARNING: Connection closed with error
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alerts.getSSLException(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
        at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
        at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
        at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
        at sun.security.ssl.Handshaker.processLoop(Unknown Source)
        at sun.security.ssl.Handshaker.process_record(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTPConnection.java:765)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPContion.java:140)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1018)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTPConnection.java:967)
        at java.lang.Thread.run(Unknown Source)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
        at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
        at sun.security.validator.Validator.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
        ... 14 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        ... 20 more May 01, 2016 10:09:31 AM org.jivesoftware.spark.util.log.Log warning
WARNING: Exception in Login:
org.jivesoftware.smack.SmackException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1025)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
        at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPath
BuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alerts.getSSLException(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
        at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
        at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
        at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
        at sun.security.ssl.Handshaker.processLoop(Unknown Source)
        at sun.security.ssl.Handshaker.process_record(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source
)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:765)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:140)
        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1018)
        ... 3 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
        at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
        at sun.security.validator.Validator.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
        ... 14 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        ... 20 more

could we be looking at a 2.8.0 release…or maybe even a 3.0

my guess would be it doesn’t like the self signed cert.

I was thinking about 2.8.0 when you have applied cstux patch and Smack 3.4.0 was almost a thing. Don’t think that 3.0.0 is necessary. Under the hood changes are not that important to the end-users. But 2.8.0 is possible

I was playing with guus’ code this weekend, and it looks like you can add (LoginDialog.java around line 248) to get around the unknown cert issue.

try {

TLSUtils.acceptAllCertificates(builder);

} catch (NoSuchAlgorithmException e) {

e.printStackTrace();

} catch (KeyManagementException e) {

e.printStackTrace();

}

after

final XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()

.setUsernameAndPassword( “username”, “password” )

.setServiceName( loginServer )

.setPort( port )

.setSendPresence( false )

.setCompressionEnabled( localPref.isCompressionEnabled() )

.setDebuggerEnabled(false);

with this, I can connect to my test install of OF, but not my production (but I think thats because im using GSSAPI on it)

Well, i have merged Smack 4 commit to the master (817 build). Still the same problem. Can’t login to my test server and to igniterealtime.org. Invalid username or password error. Same with fresh install and fresh profile. Not sure why does it work for Guss. Maybe that’s Linux vs Windows thing again

May 04, 2016 10:23:53 PM org.jivesoftware.spark.util.log.Log warning
WARNING: Exception in Login:
org.jivesoftware.smack.SmackException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1025)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
    at sun.security.ssl.Handshaker.processLoop(Unknown Source)
    at sun.security.ssl.Handshaker.process_record(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:765)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:140)
    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1018)
    ... 3 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
    at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
    ... 14 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
    at java.security.cert.CertPathBuilder.build(Unknown Source)
    ... 20 more