zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.67k stars 2.35k forks source link

Curve not working on ZeroMQ on IoS #4679

Closed robo1340 closed 5 months ago

robo1340 commented 5 months ago

Issue description

I'm working on getting ZeroMQ to compile for an Iphone app and for the life of me cannot get zmq_has("curve") to not return anything other than 0.

Environment

MacBook Pro x86_64 MacOS Sonoma Version 14.4.1 Xcode version 15.3

I'm using this guy's scripts with just a few modifications listed below: https://github.com/crcunningham/zeromq_ios_libraries

Minimal test code / Steps to reproduce the issue

Main.m in Xcode Project

#include "zmq.h"
int main(int argc, char * argv[]){
    assert(zmq_has("curve") != 0);
}

What's the actual result?

The build always succeeds with only two unrelated warnings but the assertion always fails. I am unable to use ZMQ curve security as a result.

What's the expected result?

zmq_has("curve") should return 1

Additional Info

I have tried installing libsodium with brew install libsodium and then changed the configure option --with-libzmq=yes in libzmq.sh. To my surprise, the assertion no longer failed and I was able to set curve related options on my sockets and even was able to use a REQ socket to send a command to a REP socket on another machine. I got no response back of course because without czmq I do not have the ZAP protocol implemented.

This was a comforting result to see as it proved that I have the libraries linked in Xcode correctly and am not doing anything fundamentally wrong in the way the app is making calls to zmq, but this isn't a solution for 2 reasons.

  1. I need this to compile for arm anyways to go on target hardware (a real iphone)
  2. Using the pre-compiled libsodium binary provided by brew broke the czmq build such that it would fail. Not having czmq means I couldn't make uses of the zauth_t class and would have to re-implement the ZAP protocol myself.
robo1340 commented 5 months ago

Self answering, There were some issues with the original scripts made by crcunningham, due to changes in zmq and xcode. A few tweaks got it working. I created a fork of the original repo here for anyone running into the same issue. https://github.com/robo1340/zeromq_ios_libraries