curlboringssl

How to build curl with boringssl?


I'm trying to build curl with boringssl on Ubuntu 16.04.

I have boringssl built OK.

With curl 7.53 I configure using:

./configure --with-ssl=/home/john/dev/boringssl

and the output says " SSL support: enabled (BoringSSL)" OK.

But when I make, I get errors starting with

  CC       vtls/libcurl_la-openssl.lo
In file included from vtls/openssl.c:86:0:
/usr/include/openssl/ui.h:85:1: error: unknown type name ‘UI’
 UI *UI_new(void);
 ^
/usr/include/openssl/ui.h:86:1: error: unknown type name ‘UI’
 UI *UI_new_method(const UI_METHOD *method);
 ^
/usr/include/openssl/ui.h:86:25: error: unknown type name ‘UI_METHOD’
 UI *UI_new_method(const UI_METHOD *method);
                         ^

and ending with

Makefile:2023: recipe for target 'vtls/libcurl_la-openssl.lo' failed
make[2]: *** [vtls/libcurl_la-openssl.lo] Error 1
make[2]: Leaving directory '/home/john/dev/curl-7.53.0/lib'
Makefile:734: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/john/dev/curl-7.53.0/lib'
Makefile:893: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

I'm not sure if this /usr/include/openssl/ui.h header should be used when curl is configured to build with boringssl, it seems this file only exists in OpenSSL, not boringssl.


Solution

  • There's no openssl/ui.h in the boringssl tree, your build clearly found another set of include files (plain OpenSSL I'd guess).

    This is how I build with boringssl:

    build boringssl

    $HOME/src is where I put the code in this example. You can pick wherever you like.

    $ cd $HOME/src
    $ git clone https://boringssl.googlesource.com/boringssl
    $ cd boringssl
    $ mkdir build
    $ cd build
    $ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=on ..
    $ make
    

    set up the build tree to get detected by curl's configure

    In the boringssl source tree root, make sure there's a lib and an include dir. The lib dir should contain the two libs (I make them symlinks into the build dir). The include dir is already present by default. Make and populate lib like this (commands issued in the source tree root, not in the build/ subdirectory).

    $ mkdir lib
    $ cd lib
    $ ln -s ../build/ssl/libssl.a
    $ ln -s ../build/crypto/libcrypto.a
    

    configure curl

    LIBS=-lpthread ./configure --with-ssl=$HOME/src/boringssl (where I point out the root of the boringssl tree)

    verify that at the end of the configure run, it should say it detected BoringSSL to be used

    build curl

    run make in the curl source tree

    Now you can install curl normally with make install etc.