Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-24357

Connect REST API is not working for ubuntu when installed from package and WITH_SSL=bundled

    XMLWordPrintable

Details

    Description

      CONNECT SE is a powerful SE which has a feature of using REST queries for creating/querying the tables as can be found in KB - CONNECT rest queries.
      This feature is achieved by using library which can be created as described in KB-getrest-library which is linked with libcpprest.
      To use the REST feature one should enable CONNECT_WITH_REST:BOOL=ON argument which is by default ON for the source configuration.
      After that one can manually create GetRest.so library as explained in article and dynamically link it for the usage or one can have libcpprest statically linked into the ha_connect.so plugin library.
      Now the problem here is for the later (when the libcpprest is installed and in case when using ubuntu OS. Below is the procedure shown:

      $ lsb_release -a
      No LSB modules are available.
      Distributor ID:	Ubuntu
      Description:	Ubuntu 18.04.5 LTS
      Release:	18.04
      Codename:	bionic
       
      $ dpkg -S libcpprest
      ....
      libcpprest-dev: /usr/lib/x86_64-linux-gnu/libcpprest.so
      

      Building the ha_connect.so results in no statically linked libcpprest.
      After googling found that the problem is stated here and indeed in my case:

      $ ls -la /usr/lib/x86_64-linux-gnu/cmake/ |grep cpp
      -rw-r--r--   1 root root    393 Apr 23  2018 cpprestsdk-config.cmake
      -rw-r--r--   1 root root   5268 Apr 23  2018 cpprestsdk-targets.cmake
      -rw-r--r--   1 root root    886 Apr 23  2018 cpprestsdk-targets-none.cmake
      

      Based on search procedure of cmake find_package as stated here we are ending in the result found in CMakeCache.txt in builddir:

      //The directory containing a CMake configuration file for cpprestsdk.
      cpprestsdk_DIR:PATH=cpprestsdk_DIR-NOTFOUND
      

      One way to do so is to find distro version ( I couldn't find right regex from cmake --system-information|grep CMAKE_SYSTEM ) and use lsb_release. That is suggested in the patch.

      However another problem is that this will not work when WITH_SSL=bundled (or if we are using wolfssl.
      The errors are attached in this ticket (probably will be since cannot attach the file).

      $ cmake --build . --target connect
       
      -- Ubuntu
      -- -lcpprest
      -- Configuring OQGraph
      -- Boost version: 1.65.1
      -- Performance Schema is required by TokuDB
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /home/anel/mariadb/builds/10.4
      [1/2] Building CXX object storage/connect/CMakeFiles/connect.dir/restget.cpp.o
      FAILED: storage/connect/CMakeFiles/connect.dir/restget.cpp.o 
      /usr/bin/c++  
      -DDBUG_TRACE 
      -DFORCE_INIT_OF_VARS 
      -DGZ_SUPPORT 
      -DHAVE_CONFIG_H 
      -DHUGE_SUPPORT 
      -DLIBXML2_SUPPORT 
      -DLINUX 
      -DMARIADB 
      -DMYSQL_DYNAMIC_PLUGIN 
      -DNOCRYPT 
      -DODBC_SUPPORT 
      -DREST_SOURCE 
      -DREST_SUPPORT 
      -DUBUNTU 
      -DUNIX 
      -DVCT_SUPPORT 
      -DXMAP 
      -DZIP_SUPPORT 
      -D_FILE_OFFSET_BITS=64 
      -Dconnect_EXPORTS 
      -I/home/anel/mariadb/10.4/wsrep-lib/include 
      -I/home/anel/mariadb/10.4/wsrep-lib/wsrep-API/v26 
      -Iinclude 
      -I/home/anel/mariadb/10.4/include 
      -I/home/anel/mariadb/10.4/sql 
      -Iextra/wolfssl 
      -I/home/anel/mariadb/10.4/extra/wolfssl/wolfssl 
      -I/home/anel/mariadb/10.4/extra/wolfssl/wolfssl/wolfssl 
      -I/usr/include/libxml2 
      -pie -fPIC -fstack-protector --param=ssp-buffer-size=4 -fPIC -Wall -Wmissing-declarations -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-value -Wno-error=parentheses -Wno-error=strict-aliasing -Wno-error=misleading-indentation -Wno-error=type-limits -fpermissive -fexceptions -fPIC  -g -DENABLED_DEBUG_SYNC -ggdb3 -DSAFE_MUTEX -DTRASH_FREED_MEMORY -Wall -Wextra -Wformat-security -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -Werror -Wno-unused-function -Wno-unused-variable -Wno-unused-value -Wno-parentheses -Wno-strict-aliasing -Wno-misleading-indentation -Wno-type-limits -fPIC   -std=gnu++11 -MD -MT storage/connect/CMakeFiles/connect.dir/restget.cpp.o -MF storage/connect/CMakeFiles/connect.dir/restget.cpp.o.d -o storage/connect/CMakeFiles/connect.dir/restget.cpp.o -c /home/anel/mariadb/10.4/storage/connect/restget.cpp
      In file included from /home/anel/mariadb/10.4/extra/wolfssl/wolfssl/wolfssl/ssl.h:33:0,
                       from /home/anel/mariadb/10.4/extra/wolfssl/wolfssl/wolfssl/openssl/ssl.h:35,
                       from /usr/include/boost/asio/ssl/detail/openssl_types.hpp:21,
                       from /usr/include/boost/asio/ssl/context_base.hpp:19,
                       from /usr/include/boost/asio/ssl/context.hpp:27,
                       from /usr/include/boost/asio/ssl.hpp:19,
                       from /usr/include/cpprest/http_client.h:53,
                       from /home/anel/mariadb/10.4/storage/connect/restget.cpp:6:
      /home/anel/mariadb/10.4/extra/wolfssl/wolfssl/wolfssl/wolfcrypt/settings.h:2060:14: error: #warning "For timing resistance / side-channel attack prevention consider using harden options" [-Werror=cpp]
                   #warning "For timing resistance / side-channel attack prevention consider using harden options"
                    ^~~~~~~
      In file included from /usr/include/boost/config.hpp:61:0,
                       from /usr/include/boost/algorithm/string/std_containers_traits.hpp:18,
                       from /usr/include/boost/algorithm/string.hpp:18,
                       from /usr/include/cpprest/asyncrt_utils.h:31,
                       from /usr/include/cpprest/astreambuf.h:23,
                       from /usr/include/cpprest/filestream.h:19,
                       from /home/anel/mariadb/10.4/storage/connect/restget.cpp:5:
      /usr/include/boost/asio/ssl/context_base.hpp:127:3: error: ‘SSL_OP_ALL’ was not declared in this scop....
      

      In order to solve this easiest solution is to use WITH_SSL=system.
      When applying the patch and building the binaries correct result is obtained:

      $ ldd ./storage/connect/ha_connect.so |grep cpp
      	libcpprest.so.2.10 => /usr/lib/x86_64-linux-gnu/libcpprest.so.2.10 (0x00007f5f8f760000)
      

      Attachments

        1. wolfssl_error.txt
          41 kB
        2. tabrest.cpp
          11 kB
        3. tabrest.h
          2 kB

        Issue Links

          Activity

            People

              bertrandop Olivier Bertrand
              anel Anel Husakovic
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.