open-quantum-safe / oqs-demos

PARTIALLY SUPPORTED Instructions for enabling the use of quantum-safe cryptography in assorted software using the OQS suite. CONTRIBUTORS WANTED.
https://openquantumsafe.org/
132 stars 74 forks source link

Failed to build httpd on Mac M1 #248

Closed NomanNasirMinhas closed 11 months ago

NomanNasirMinhas commented 1 year ago

I am building httpd demo on Mac M1 Pro, but is failing with following error trace.

docker build -t oqs-httpd-img .

[+] Building 7.4s (17/33)                                                                                                                                                    docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                         0.0s
 => => transferring dockerfile: 6.39kB                                                                                                                                                       0.0s
 => [internal] load .dockerignore                                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/alpine:3.13                                                                                                                               4.1s
 => [auth] library/alpine:pull token for registry-1.docker.io                                                                                                                                0.0s
 => [internal] load build context                                                                                                                                                            0.0s
 => => transferring context: 119B                                                                                                                                                            0.0s
 => [stage-1  1/11] FROM docker.io/library/alpine:3.13@sha256:469b6e04ee185740477efa44ed5bdd64a07bbdd6c7e5f5d169e540889597b911                                                               0.0s
 => CACHED [stage-1  2/11] RUN apk add pcre-dev expat-dev                                                                                                                                    0.0s
 => CACHED [intermediate  2/18] RUN apk add build-base linux-headers             libtool automake autoconf cmake ninja             make             git wget pcre-dev             expat-dev  0.0s
 => CACHED [intermediate  3/18] WORKDIR /opt                                                                                                                                                 0.0s
 => CACHED [intermediate  4/18] RUN git clone --depth 1 --branch main https://github.com/open-quantum-safe/liboqs &&     git clone --depth 1 --branch master https://github.com/openssl/ope  0.0s
 => CACHED [intermediate  5/18] WORKDIR /opt/ossl-src                                                                                                                                        0.0s
 => CACHED [intermediate  6/18] RUN ./config no-shared --prefix=/opt/openssl &&     make -j 2 && make install_sw install_ssldirs &&     ln -s /opt/openssl/lib64 /opt/openssl/lib;           0.0s
 => CACHED [intermediate  7/18] WORKDIR /opt/liboqs                                                                                                                                          0.0s
 => CACHED [intermediate  8/18] RUN mkdir build && cd build && cmake -G"Ninja" .. -DOQS_DIST_BUILD=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/opt/openssl && ninja && ninja install   0.0s
 => CACHED [intermediate  9/18] RUN sed -i "s/default = default_sect/default = default_sect\noqsprovider = oqsprovider_sect/g" /opt/openssl/ssl/openssl.cnf && sed -i "s/\[default_sect\]/\  0.0s
 => CACHED [intermediate 10/18] WORKDIR /opt/oqs-provider                                                                                                                                    0.0s
 => ERROR [intermediate 11/18] RUN rm -rf build && cmake -DCMAKE_BUILD_TYPE=Debug -DOPENSSL_ROOT_DIR=/opt/openssl -DCMAKE_PREFIX_PATH=/opt/openssl -S . -B build && cmake --build build &&   3.2s
------
 > [intermediate 11/18] RUN rm -rf build && cmake -DCMAKE_BUILD_TYPE=Debug -DOPENSSL_ROOT_DIR=/opt/openssl -DCMAKE_PREFIX_PATH=/opt/openssl -S . -B build && cmake --build build && cp build/lib/oqsprovider.so /opt/openssl/lib64/ossl-modules/oqsprovider.so:
0.260 -- The C compiler identification is GNU 10.2.1
0.271 -- Detecting C compiler ABI info
0.310 -- Detecting C compiler ABI info - done
0.324 -- Check for working C compiler: /usr/bin/cc - skipped
0.324 -- Detecting C compile features
0.325 -- Detecting C compile features - done
0.326 -- Creating Debug build with OQS-Debug env vars enabled
0.326 -- Build will store public keys in PKCS#8 structures
0.326 -- Build will not include external encoding library for SPKI/PKCS#8
0.336 -- Looking for pthread.h
0.372 -- Looking for pthread.h - found
0.373 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
0.406 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
0.408 -- Found Threads: TRUE
0.410 -- Found OpenSSL: /opt/openssl/lib/libcrypto.a (found suitable version "3.3.0", minimum required is "3.0")
0.412 -- liboqs found: Include dir at /opt/openssl/include;/opt/openssl/include/oqs
0.425 -- Building commit 4dac252 in /opt/oqs-provider
0.442 -- Configuring done
0.450 -- Generating done
0.451 -- Build files have been written to: /opt/oqs-provider/build
0.466 Scanning dependencies of target oqsprovider
0.496 [  3%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqsprov.c.o
0.576 [  7%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqsprov_capabilities.c.o
0.709 [ 10%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqsprov_keys.c.o
0.827 [ 14%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqs_kmgmt.c.o
0.950 [ 17%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqs_sig.c.o
1.051 [ 21%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqs_kem.c.o
1.121 [ 25%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqs_encode_key2any.c.o
1.557 [ 28%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqs_endecoder_common.c.o
1.596 [ 32%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqs_decode_der2key.c.o
1.726 [ 35%] Building C object oqsprov/CMakeFiles/oqsprovider.dir/oqsprov_bio.c.o
1.774 [ 39%] Linking C shared module ../lib/oqsprovider.so
1.802 [ 39%] Built target oqsprovider
1.806 Scanning dependencies of target oqs_test_groups
1.817 [ 42%] Building C object test/CMakeFiles/oqs_test_groups.dir/oqs_test_groups.c.o
1.903 [ 46%] Building C object test/CMakeFiles/oqs_test_groups.dir/test_common.c.o
1.934 [ 50%] Building C object test/CMakeFiles/oqs_test_groups.dir/tlstest_helpers.c.o
2.017 [ 53%] Linking C executable oqs_test_groups
2.173 [ 53%] Built target oqs_test_groups
2.176 Scanning dependencies of target oqs_test_kems
2.184 [ 57%] Building C object test/CMakeFiles/oqs_test_kems.dir/oqs_test_kems.c.o
2.243 [ 60%] Building C object test/CMakeFiles/oqs_test_kems.dir/test_common.c.o
2.274 [ 64%] Linking C executable oqs_test_kems
2.385 [ 64%] Built target oqs_test_kems
2.388 Scanning dependencies of target oqs_test_tlssig
2.400 [ 67%] Building C object test/CMakeFiles/oqs_test_tlssig.dir/oqs_test_tlssig.c.o
2.483 [ 71%] Building C object test/CMakeFiles/oqs_test_tlssig.dir/test_common.c.o
2.513 [ 75%] Building C object test/CMakeFiles/oqs_test_tlssig.dir/tlstest_helpers.c.o
2.596 [ 78%] Linking C executable oqs_test_tlssig
2.725 [ 78%] Built target oqs_test_tlssig
2.729 Scanning dependencies of target oqs_test_endecode
2.740 [ 82%] Building C object test/CMakeFiles/oqs_test_endecode.dir/oqs_test_endecode.c.o
2.826 [ 85%] Building C object test/CMakeFiles/oqs_test_endecode.dir/test_common.c.o
2.857 [ 89%] Linking C executable oqs_test_endecode
2.966 [ 89%] Built target oqs_test_endecode
2.969 Scanning dependencies of target oqs_test_signatures
2.977 [ 92%] Building C object test/CMakeFiles/oqs_test_signatures.dir/oqs_test_signatures.c.o
3.039 [ 96%] Building C object test/CMakeFiles/oqs_test_signatures.dir/test_common.c.o
3.069 [100%] Linking C executable oqs_test_signatures
3.180 [100%] Built target oqs_test_signatures
3.185 cp: can't create '/opt/openssl/lib64/ossl-modules/oqsprovider.so': No such file or directory
------
Dockerfile:81
--------------------
  79 |     # build oqs-provider
  80 |     WORKDIR /opt/oqs-provider
  81 | >>> RUN rm -rf build && cmake -DCMAKE_BUILD_TYPE=Debug -DOPENSSL_ROOT_DIR=${OPENSSL_PATH} -DCMAKE_PREFIX_PATH=${OPENSSL_PATH} -S . -B build && cmake --build build && cp build/lib/oqsprovider.so ${OPENSSL_PATH}/lib64/ossl-modules/oqsprovider.so
  82 |
  83 |     # build httpd
--------------------
ERROR: failed to solve: process "/bin/sh -c rm -rf build && cmake -DCMAKE_BUILD_TYPE=Debug -DOPENSSL_ROOT_DIR=${OPENSSL_PATH} -DCMAKE_PREFIX_PATH=${OPENSSL_PATH} -S . -B build && cmake --build build && cp build/lib/oqsprovider.so ${OPENSSL_PATH}/lib64/ossl-modules/oqsprovider.so" did not complete successfully: exit code: 1
baentsch commented 11 months ago

Fascinating error: For some reason, openssl in an alpine image on Apple HW installs providers to a different directory than on x64 hardware (lib rather than lib64): By changing the erring line above to ... ${OPENSSL_PATH}/lib/ossl-modules/oqsprovider.so in the Dockerfile everything will work OK. Let me think about a long-term fix.