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

ssl support #10

Open
rolandjitsu opened this issue May 17, 2014 · 31 comments
Open

ssl support #10

rolandjitsu opened this issue May 17, 2014 · 31 comments

Comments

@rolandjitsu
Copy link

Does the Objective-C implementation of the mosquito lib support TLS connections?

@jmesnil
Copy link
Contributor

jmesnil commented May 17, 2014

Mosquitto does support TLS but I've not yet added it to MQTTKit.

I have a branch (https://github.com/jmesnil/MQTTKit/tree/TLS_support) for this feature but it's not completed yet

@smzarrin
Copy link

Hi Jeff

I do need the open SSL Version. Do you know of any other Kit that does the TLS or could you help me write the wrapper for mosquitto_tls_set. Our broker uses open ssl and port 8884. Thanks in advance,

@jmesnil
Copy link
Contributor

jmesnil commented May 26, 2014

@smzarrin, I'm currently adding TLS support to MQTTKit in this branch https://github.com/jmesnil/MQTTKit/tree/TLS_support but have not thoroughly tested it.

If you could try it and confirm that it works for you, I may merge it in upstream.

@jmesnil jmesnil reopened this May 26, 2014
@ckrey
Copy link

ckrey commented May 27, 2014

The reason I started my own https://github.com/ckrey/MQTT-Client-Framework was the fact that a year ago there was no SSL support in MQTTKit.

MQTT-Client-Framework supports TLS, MQTT spec 3.1.1 and is the base for @owntracks (http://owntracks.org) and MQTTInspector apps. Both apps are quite stable. For MQTTInspector I added some low level delegate methods too.

MQTT-Client-Framework is fully native Objective-C and builds on Apple's CFNetwork layer.

Let me know when your SSL support is finished.

@jmesnil
Copy link
Contributor

jmesnil commented May 28, 2014

MQTTKit did not exist one year ago ;)
(but mosquito which is used underneath was already supporting TSL).

@ckrey What are the main differences between your lib and 2lemetry/eclipse pano Obj-c client?

@ckrey
Copy link

ckrey commented May 28, 2014

MQTT-Client-Framework started as a fork of m2mIO/mqttIO-objC (the predecessor of the Obj-c client under eclipse).

At that time there were problems with ARC support, SSL was not visible on the public interface, etc.
Unfortunately the maintainers did not respond to issues and even pull requests.

So, I started off to go independently - now there are the following differences although the core code is still 2lemetry:

  • full ARC - easily integrates in current developements
  • Framework packaging - easily to be imported in projects without the need for pod
  • disconnect command and reconnect including additionall closing state - important in IOS, because otherwise you loose connection when the app is going to background
  • Using of explicit delegate protocols
  • Extended delegate callbacks to SUBACK, UNSUBACK, command send and receive
  • fixed some 64 bit issues
  • Tested and used in MQTTitude and MQTTInspectore apps available in the app store
  • fixed timing issues caused by using usleep
  • changed the implementation of retransmits to avoid timing and background issues
  • support for new MQTT 3.1.1 spec (protocol level 4)
  • test cases
  • inline docs

I hope we will find a way to bring Objective-C MQTT libraries together again and profit from wider use, testing, and contributions...

@ckrey
Copy link

ckrey commented May 28, 2014

@jmesnil How do you feel using OpenSSL on IOS (footprint, complexity, stability)?

@mysticvalley
Copy link

@jmesnil Hello Jeff, I am using MQTTKit for a messaging app. My broker uses SSL connection. So I am searching for SSL support in the MQTTKit.

I checked out your code and new branch (https://github.com/jmesnil/MQTTKit/tree/TLS_support) for TLS_support as mentioned above. However I don't find any method that implements SSL connection with certificates. Can you please let me know if the branch has SSL support implementation or not? Or let me know if i didn't knew how to use it.

Thanks

@jmesnil
Copy link
Contributor

jmesnil commented Jun 16, 2014

@mysticboy59 You can specify a CA file on the MQTT client (as it is done in the test https://github.com/jmesnil/MQTTKit/blob/TLS_support/MQTTKitTests/MQTTKitTests.m#L227).

Note that this branch is a proof of concept. I am not sure whether it is a good idea to rely on OpenSSL for TLS given the recent issues with it.

@zwf
Copy link

zwf commented Oct 17, 2014

@jmesnil Hello Jeff, seems the TLS_support branch could not be compiled correctly, cause the WITH_TLS not defined.

@viteinfinite
Copy link

Worked perfectly with pod 'OpenSSL-Framework', '~> 1.0'

@GuriSarao
Copy link

I am using https://github.com/jmesnil/MQTTKit/blob/TLS_support/MQTTKitTests/MQTTKitTests.m#L227).
can any one help me. it give me error message.

@kirang89
Copy link

mosquitto_tls_set keeps returning MOSQ_ERR_NOT_SUPPORTED because WITH_TLS is not defined. How can I set this @jmesnil ?

@zwf
Copy link

zwf commented May 1, 2015

@GuriSarao @kirang89 I forked @jmesnil 's repo and finished the TLS_support branch, just for testing my project. My codes are not good enough for production, you should consummate that codes before use in an online app I think. :)
https://github.com/zwf/MQTTKit/tree/TLS_support

@kirang89
Copy link

kirang89 commented May 2, 2015

@zwf I tried adding -DWITH_TLS=1 as a compiler flag and got it to work. I forked your branch anyways and tested it out as well. Seems to work fine for now :) Thanks for sharing your repo!

@GuriSarao
Copy link

Hi can you please send me your working source code as i am already stuck in this from last 2 week and can't get any solution yet. My email is is gursewaks104@gmail.com. I will be very thankful to you.

@kirang89
Copy link

kirang89 commented May 2, 2015

@GuriSarao Checkout @zwf 's fork. It works fine for me.

@kirang89
Copy link

kirang89 commented May 2, 2015

@viteinfinite Did you have issues with OpenSSL-Universal ?

@GuriSarao
Copy link

I am getting same error with @zwf fork when i define WITH_TLS.there are lots of error come in my code when i define WITH_TLS. can anyone have solution?

@kirang89
Copy link

kirang89 commented May 5, 2015

@GuriSarao You don't have to define anything. Just add
pod 'MQTTKit', :git => 'https://github.com/zwf/MQTTKit', :branch => 'TLS_support'
to your Podfile, pod install it and run your project. If that failed as well, could you provide a link to your repo so that I can take a look at it ?

@zwf
Copy link

zwf commented May 8, 2015

@GuriSarao just follow @kirang89 's comment :) thx @kirang89
and it's better to use :comment not :branch, that is good for pod to download the right codes, cause I'll push some codes some day, maybe~ :)

pod 'MQTTKit', :git => 'https://github.com/zwf/MQTTKit.git', :commit => '15ba0a41f'

@kirang89
Copy link

kirang89 commented May 9, 2015

@zwf I keep getting EXC_BAD_ACCESS issues when trying to load one client after another. Have you faced such issues ?

@zwf
Copy link

zwf commented May 12, 2015

@kirang89 I didn't face this. I guess the issue brought by async part in MQTTKit.

@kirang89
Copy link

My thoughts exactly. I raised it as an issue (#31).

@devTechi
Copy link

Hi. Will there be a chance that the branch will get merged to master original repo? Thanks.

@nablavector
Copy link

bump

@crystaldonut
Copy link

bump because this is a great feature!

@viniciusmo
Copy link

bump because this is a great feature![2]

@julianjohn
Copy link

@kirang89 / @zwf Im also trying to integrate zwf's implementation. But facing some issues in connecting to the server.

Im trying to connect to a mqtt server with verisign signed cert. What are the parameter i need to set in the client. Tried setting tlsInsecure to false and also set PEM encoded cert for the cafile. nothing seems to work am i missing something? Need help badly.
Could you kindly share any example project for me to refer. Thanks.

@kirang89
Copy link

I just used @zwf's fork and got it to work well.

I had to setup MQTT with TLS for work, but I ended up using a non-TLS implementation because of threading issues. Unfortunately I don't have any project that I can share but I'll try and highlight a few key things I did:

  • Set the TLS support branch in your Podfile like so:

     pod 'MQTTKit', :git => 'https://github.com/zwf/MQTTKit/tree/TLS_support', :branch => 'TLS_support'
    
  • Setup client appropriately before connecting:

    MQTTClient *client = [[MQTTClient alloc]initWithClientId:id];
    [client setUsername:username];
    [client setPassword:password];
    
  • Set the CA file to use for server validation

    [client setCafile:[[NSBundle mainBundle]pathForResource:@"ca" ofType:@"crt"]]
    
  • Finally connect to the server

    [client connectToHost:MQSERVER completionHandler:handler];
    

@ndmeiri
Copy link

ndmeiri commented Mar 3, 2016

Is it possible to use @zwf's fork without a username and password? I'm using the AWS IoT MQTT broker and it doesn't support username/password credentials. It will only accept a CA file and certificates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests