theinvisible / openfortigui

VPN-GUI to connect to Fortigate-Hardware, based on openfortivpn
https://hadler.me/linux/openfortigui/
GNU General Public License v3.0
490 stars 54 forks source link

Building from source for macOS #56

Closed khwj closed 5 years ago

khwj commented 5 years ago

openfortigui is such a great open source, I always prefer using openfortigui with openfortivpn when I was using a Linux machine mainly because openfortivpn is capable of connecting multiple VPNs simultaneously and I'm more comfortable using open sources.

Now I'm switch to Mac and there is no alternative other than official Forti client which lack the features I mentioned above.

I'm aware that openfortigui is not officially support macOS at the moment (and probably not plan to) and I'm not an expert in qt and c++ so let me know if I'm wrong.

Here are my assumptions:

If the above assumptions are correct this might be just the matter of lacking build instruction for macOS.

I have followed the build instruction and adapt it for macOS and stuck with a few issues and need some advise.

Steps I've taken so far:

  1. Install Xcode from Mac App Store and install Xcode's command-line tools using sudo xcode-select --install
  2. Install Homebrew package manager
  3. Install openfortivpn 1.7.1 brew install openfortivpn
  4. Install OpenSSL library (1.0.2p)
    brew install openssl
    echo 'export PATH=/usr/local/opt/openssl/include:$PATH' >> ~/.bash_profile
    echo 'export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH' >> ~/.bash_profile
    echo 'export LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"' >> ~/.bash_profile
    echo 'export CPPFLAGS="-I/usr/local/opt/openssl/include $CPPFLAGS"' >> ~/.bash_profile
  5. Install Qt5 (5.11.1)
    brew install qt5
    echo 'export PATH=/usr/local/opt/qt/bin:$PATH' >> ~/.bash_profile
    echo 'export PKG_CONFIG_PATH=/usr/local/opt/qt/lib/pkgconfig:$PKG_CONFIG_PATH' >> ~/.bash_profile
    echo 'export LDFLAGS="-L/usr/local/opt/qt/lib $LDFLAGS"' >> ~/.bash_profile
    echo 'export CPPFLAGS="-I/usr/local/opt/qt/include $CPPFLAGS"' >> ~/.bash_profile
  6. Install QtKeychain (0.9.1)
    brew install qtkeychain 
    echo 'LDFLAGS=/usr/local/opt/qtkeychain/lib $LDFLAGS"' >> ~/.bash_profile
    echo 'CPPFLAGS=/usr/local/opt/qtkeychain/include $CPPFLAGS"' >> ~/.bash_profile
  7. Install cryptopp (7.0.0)
    brew install cryptopp 
    echo 'LDFLAGS=/usr/local/opt/cryptopp/lib $LDFLAGS"' >> ~/.bash_profile
    echo 'CPPFLAGS=/usr/local/opt/cryptopp/include $CPPFLAGS"' >> ~/.bash_profile
  8. Clone the repository and it's submodules
    git clone https://github.com/theinvisible/openfortigui.git
    cd openfortigui && git submodule init && git submodule update
  9. Finally, we build the application qmake && make -j4

In the last step, I got the following error

vpnhelper.cpp:51:72: error: parameter declarator cannot be qualified
    QKeychain::WritePasswordJob job(QLatin1String(openfortigui_config::password_manager_namespace));
                                                  ~~~~~~~~~~~~~~~~~~~~~^
vpnhelper.cpp:51:36: warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
    QKeychain::WritePasswordJob job(QLatin1String(openfortigui_config::password_manager_namespace));
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vpnhelper.cpp:51:37: note: add a pair of parentheses to declare a variable
    QKeychain::WritePasswordJob job(QLatin1String(openfortigui_config::password_manager_namespace));
                                    ^
                                    (                                                             )
vpnhelper.cpp:52:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.setAutoDelete(false);
    ~~~^~~~~~~~~~~~~~
vpnhelper.cpp:53:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.setKey("testkeystore");
    ~~~^~~~~~~
vpnhelper.cpp:54:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.setBinaryData("test");
    ~~~^~~~~~~~~~~~~~
vpnhelper.cpp:56:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.connect(&job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
    ~~~^~~~~~~~
vpnhelper.cpp:57:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.start();
    ~~~^~~~~~
vpnhelper.cpp:59:11: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    if(job.error())
       ~~~^~~~~~
vpnhelper.cpp:62:25: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
        result.msg = job.errorString();
                     ~~~^~~~~~~~~~~~
vpnhelper.cpp:66:74: error: parameter declarator cannot be qualified
    QKeychain::DeletePasswordJob job2(QLatin1String(openfortigui_config::password_manager_namespace));
                                                    ~~~~~~~~~~~~~~~~~~~~~^
vpnhelper.cpp:66:38: warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
    QKeychain::DeletePasswordJob job2(QLatin1String(openfortigui_config::password_manager_namespace));
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vpnhelper.cpp:66:39: note: add a pair of parentheses to declare a variable
    QKeychain::DeletePasswordJob job2(QLatin1String(openfortigui_config::password_manager_namespace));
                                      ^
                                      (                                                             )
vpnhelper.cpp:67:9: error: member reference base type 'QKeychain::DeletePasswordJob (QLatin1String)' is not a structure or union
    job2.setAutoDelete(false);
    ~~~~^~~~~~~~~~~~~~
vpnhelper.cpp:68:9: error: member reference base type 'QKeychain::DeletePasswordJob (QLatin1String)' is not a structure or union
    job2.setKey("testkeystore");
    ~~~~^~~~~~~
vpnhelper.cpp:70:9: error: member reference base type 'QKeychain::DeletePasswordJob (QLatin1String)' is not a structure or union
    job2.connect(&job2, SIGNAL(finished(QKeychain::Job*)), &loop2, SLOT(quit()));
    ~~~~^~~~~~~~
vpnhelper.cpp:71:9: error: member reference base type 'QKeychain::DeletePasswordJob (QLatin1String)' is not a structure or union
    job2.start();
    ~~~~^~~~~~
vpnhelper.cpp:73:12: error: member reference base type 'QKeychain::DeletePasswordJob (QLatin1String)' is not a structure or union
    if(job2.error())
       ~~~~^~~~~~
vpnhelper.cpp:76:26: error: member reference base type 'QKeychain::DeletePasswordJob (QLatin1String)' is not a structure or union
        result.msg = job2.errorString();
                     ~~~~^~~~~~~~~~~~
vpnhelper.cpp:89:72: error: parameter declarator cannot be qualified
    QKeychain::WritePasswordJob job(QLatin1String(openfortigui_config::password_manager_namespace));
                                                  ~~~~~~~~~~~~~~~~~~~~~^
vpnhelper.cpp:89:36: warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
    QKeychain::WritePasswordJob job(QLatin1String(openfortigui_config::password_manager_namespace));
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vpnhelper.cpp:89:37: note: add a pair of parentheses to declare a variable
    QKeychain::WritePasswordJob job(QLatin1String(openfortigui_config::password_manager_namespace));
                                    ^
                                    (                                                             )
vpnhelper.cpp:90:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.setAutoDelete(false);
    ~~~^~~~~~~~~~~~~~
vpnhelper.cpp:91:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.setKey(key);
    ~~~^~~~~~~
vpnhelper.cpp:92:8: error: member reference base type 'QKeychain::WritePasswordJob (QLatin1String)' is not a structure or union
    job.setBinaryData(data.toUtf8());
    ~~~^~~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 warnings and 20 errors generated.
make[1]: *** [vpnhelper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
2 warnings generated.
make: *** [sub-openfortigui-make_first] Error 2

Please advise.

SkyCrawl commented 5 years ago

I'm not one of the project's maintainers and just recently tried the same (using MacPorts, not HomeBrew). I got past these errors by enclosing the "wrong" statement in yet another pair of parenthesis, so e.g.

QKeychain::WritePasswordJob job(QLatin1String(openfortigui_config::password_manager_namespace));

becomes

QKeychain::WritePasswordJob job ((QLatin1String(openfortigui_config::password_manager_namespace)));

The problem is that once I built the project and ran it in QT Creators IDE, no buttons of OpenFortiGUI worked and debugging somehow didn't work either. After several failed attempts to get it working, I lost patience but don't get discouraged - you may have more knowledge/time/motivation/luck than me :). I think I compiled against Qt 5.11 though and if (e.g.) "only" Qt 5.5 is supported, problems could arise.

Also note that you'll probably need to remove the :!macx piece of code from the project's .pro file to successfully compile. If you haven't done so yet, of course.

Oh and one more thing. In my case (MacPorts), I also had to edit the .pro file as follows to successfully compile against OpenSSL:

unix:!symbian: LIBS += -L/opt/local/include -lcrypto -lpthread -lssl -lutil -lqt5keychain
khwj commented 5 years ago

@SkyCrawl thanks for the really helpful advise. I proceeded to add extra pair of parenthesises, removed :!macx as recommended and I am able to build the project without any error.

The icons seems to work except for the App Icon/Dock Icon.

screen shot 2561-08-28 at 15 30 16

The main menu, the tray menu, About window and the Settings also seem to work as well. However, I cannot click anything on the main window, cannot click anything on the Initial Setup wizard and cannot open the Preferences (which is the most important).

I've never used Qt Creator before but Debug mode seems to work though.

screen shot 2561-08-28 at 15 22 10

I need more advise and I still have no idea what I'm doing. I also hope someone would pick this up and complete it and probably motivate those who lost patience :) (@SkyCrawl perhaps?).

Ping @theinvisible .

For now, I’m going to commit my change and create a PR soon.

Note that I still compiled with Qt5 v11.1 (tried to downgrade to v5.5, or even v5.6, with no success).

screen shot 2561-08-28 at 15 30 32
SkyCrawl commented 5 years ago

@khwunchai you're welcome :).

However, I cannot click anything on the main window, cannot click anything on the Initial Setup wizard and cannot open the Preferences (which is the most important).

That was my problem too and I was unable to get past it. And I lost patience because I couldn't find anything on this on the internet and came to believe that solid QT knowledge was necessary to move on (although the issue is most likely caused by something really trivial).

Anyway, how did you get the windows in screenshots 1 and 3 to appear?

EDIT:

Ah, I suppose you used the tray icon?

theinvisible commented 5 years ago

Hi,

thanks for your effort for supporting MacOS.

As i said once i can not provide support as i dont have any Apple devices here. I just can say that it MAY work as openfortivpn runs on Mac and Qt in general also does.

I have also now merged your requested fixes to compile on MacOS.

I cant say why the UI on MacOS is not working as expected, maybe there are some MacOS required fixes needed? I dont know really as long as i cant get a MacOS device for testing.

Cheers Rene

khwj commented 5 years ago

I'll close this issue now, unresponsive UI should be treated as a separate topic as this issue is only regard building process. Maybe I'll add instruction for building from source for MacOS as well and hopefully someone will pick up and fix it🤞.

Thanks!

P.S. @SkyCrawl Indeed I used the tray icon lol.

wadkar commented 5 years ago

/subscribe looking forward to the GUI building on my High Sierra - lmk if I can help with bottling it up for brew

jahirfiquitiva commented 5 years ago

Are there any news on this? Would love to be able to use this client on macOS as the official client is super laggy and awful to use 😭

rhaamo commented 5 years ago

Here is the needed stuff to do to the .pro to build it:

diff --git a/openfortigui/openfortigui.pro b/openfortigui/openfortigui.pro
index cd1f88a..b8485db 100644
--- a/openfortigui/openfortigui.pro
+++ b/openfortigui/openfortigui.pro
@@ -84,9 +84,9 @@ FORMS    += mainwindow.ui \
 RESOURCES += \
     res.qrc

-OPENFORTIVPN_FLAGS = -DHAVE_USR_SBIN_PPPD=1 -DHAVE_PROC_NET_ROUTE=1 -DHAVE_STRUCT_TERMIOS=1 -DHAVE_RT_ENTRY_WITH_RT_DST=1 -DHAVE_SYSTEMD=0 -DHAVE_X509_CHECK_HOST=1 -DPPP_PATH=\\\"/usr/sbin/pppd\\\"
-QMAKE_CFLAGS += $$(CPPFLAGS) $${OPENFORTIVPN_FLAGS}
-QMAKE_CXXFLAGS += $${OPENFORTIVPN_FLAGS}
-QMAKE_LFLAGS += $$(LDFLAGS)
+OPENFORTIVPN_FLAGS = -DHAVE_USR_SBIN_PPPD=1 -DHAVE_PROC_NET_ROUTE=1 -DHAVE_STRUCT_TERMIOS=1 -DHAVE_SYSTEMD=0 -DHAVE_X509_CHECK_HOST=1 -DPPP_PATH=\\\"/usr/sbin/pppd\\\"
+QMAKE_CFLAGS += $$(CPPFLAGS) $${OPENFORTIVPN_FLAGS} -I/usr/local/opt/openssl/include -I/usr/local/opt/qtkeychain/include
+QMAKE_CXXFLAGS += $${OPENFORTIVPN_FLAGS} -I/usr/local/opt/openssl/include -I/usr/local/opt/qtkeychain/include
+QMAKE_LFLAGS += $$(LDFLAGS) -L/usr/local/opt/qtkeychain/lib

It's possible to bypass the wizard with the tray icon -> settings -> save, force kill and set setupwizard=true in ~/.openfortigui/main.conf.

I've tried adding a vpn, but connection doesn't work pass the "accept cert" and it segfaulted when clicking on "disconnect".

Now the gui doesn't start and log:

juin 9 22:42:37 openfortiGUI::Debug: "start-main::"
juin 9 22:42:37 openfortiGUI::Warning: "QLocalSocket::connectToServer : Connection refused"

So for my part I will stick with the CLI client for now.

Would providing a remote desktop/ssh access to a mac helps in making the GUI more stable ?

Morteza-Rastgoo commented 3 years ago

Any updates on this?

radekskr commented 2 years ago

Hi, I also use the OpenFortiGUI on Linux. It is very very good software. Now I am testing MacBookAir and I lookup alternative vpn client for official Forticlient, because it is slow, bad and it can not multi connection at the same time.

Maybe an idea. If Rene Hadler was interested? Wouldn't it be possible to create a collection to buy a test macbook for him? I would very much like to contribute as far as I can. Maybe there would be more people with the same interest.

-- Radek

karol-f commented 2 years ago

@radekskr for now you can use CLI - https://github.com/adrienverge/openfortivpn

e.g.

openfortivpn url-to-host:<port> --username=<user> --password=<pass> --persistent=5

You can get that info from FortiClient Console

screenshot_193

marcelstoer commented 1 year ago

I too am looking forward to someone who managed to build/run this on macOS to maybe add instructions to the project documentation.

karol-f commented 1 year ago

On OSX you can use CLI openfortivpn (install it with Homebrew) :

sudo openfortivpn your-vpn-gateway:8443

Or you can check openfortivpn OSX wrapper I build for myself. Maybe it will help you - https://github.com/karol-f/openfortivpn-osx-wrapper

forti-wrapper-osx

ms-dosx86 commented 10 months ago

On OSX you can use CLI openfortivpn (install it with Homebrew) :

sudo openfortivpn your-vpn-gateway:8443

Or you can check openfortivpn OSX wrapper I build for myself. Maybe it will help you - https://github.com/karol-f/openfortivpn-osx-wrapper

forti-wrapper-osx

Thank you! I wasted like a whole day trying to get FortiClient to work and was able to connect via openfortivpn