Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2Uq2-00026Q-Sl for pgsql-interfaces@arkaria.postgresql.org; Tue, 06 Dec 2022 10:06:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2Uq0-0003AK-TL for pgsql-interfaces@arkaria.postgresql.org; Tue, 06 Dec 2022 10:06:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2Uq0-0003A9-MO for pgsql-interfaces@lists.postgresql.org; Tue, 06 Dec 2022 10:06:08 +0000 Received: from mail2.g1.pair.com ([66.39.3.168]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2Upv-0004Hh-Nt for pgsql-interfaces@lists.postgresql.org; Tue, 06 Dec 2022 10:06:07 +0000 Received: from mail2.g1.pair.com (localhost [127.0.0.1]) by mail2.g1.pair.com (Postfix) with ESMTP id 8A09E832467; Tue, 6 Dec 2022 05:06:01 -0500 (EST) Received: from smtpclient.apple (host-95-233-97-166.retail.telecomitalia.it [95.233.97.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail2.g1.pair.com (Postfix) with ESMTPSA id 1E40A844B73; Tue, 6 Dec 2022 05:06:00 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.200.110.1.12\)) Subject: Re: Libpq linked statically linked to OpenSSL/LibreSSL From: Marco Bambini In-Reply-To: <7B10A8B6-04E3-49F3-AB0D-413E8B0AC365@creolabs.com> Date: Tue, 6 Dec 2022 11:05:49 +0100 Cc: "pgsql-interfaces@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <10650109-6ECE-4F7D-9014-2785AA2D413B@creolabs.com> References: <7B10A8B6-04E3-49F3-AB0D-413E8B0AC365@creolabs.com> To: =?utf-8?Q?ALBERTO_CABELLO_S=C3=81NCHEZ?= X-Mailer: Apple Mail (2.3731.200.110.1.12) X-Scanned-By: mailmunge 3.10 on 66.39.3.168 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I made some progresses, especially in understanding where the issue can = be. I started with a fresh postgresql-15.1 source code installation: # ./configure --with-openssl --without-readline I then modified the Makefile.global in the src directory by replacing = the occurrences of -lssl and -lcrypto with: /root/rothsoft/libressl-3.6.1/ssl/.libs/libssl.a = /root/rothsoft/libressl-3.6.1/crypto/.libs/libcrypto.a in the LIBS entry. Then from src/interfaces/libpq I executed: # make libpq was successfully created but when I perform a: # nm -D libpq.so the output looks like: 000000000001f110 T appendBinaryPQExpBuffer 000000000001f000 T appendPQExpBuffer 000000000001f0d0 T appendPQExpBufferChar 000000000001f150 T appendPQExpBufferStr U ASN1_STRING_data U ASN1_STRING_length U BIO_clear_flags U BIO_int_ctrl U BIO_new U BIO_set_flags U BIO_s_socket U calloc U close U connect 000000000001ecd0 T createPQExpBuffer U CRYPTO_get_id_callback U CRYPTO_get_locking_callback U CRYPTO_num_locks U CRYPTO_set_id_callback U CRYPTO_set_locking_callback U __ctype_b_loc U __ctype_tolower_loc U __ctype_toupper_loc w __cxa_finalize 000000000001ed30 T destroyPQExpBuffer U ENGINE_by_id U ENGINE_finish U ENGINE_free U ENGINE_init U ENGINE_load_private_key 000000000001ed90 T enlargePQExpBuffer U ERR_clear_error U ERR_get_error U __errno_location U ERR_put_error U ERR_reason_error_string U EVP_DigestFinal_ex U EVP_DigestInit_ex ... Please notice all the U entries in the crypto/ssl functions, so it looks = like that they are NOT statically linked inside the libpq.so shared = library, even if I replaced the LIBS in the Makefile. Anyone can help me with this issue? Thanks, Marco > On 5 Dec 2022, at 17:47, Marco Bambini wrote: >=20 > Thanks Alberto, >=20 > This is a very promising approach. >=20 > I tried to modify the Makefile in src/interfaces/libpq/Makefile and I = replaced the occurrences of -lssl and -lcrypto with: > /root/rothsoft/libressl-3.6.1/ssl/.libs/libssl.a > /root/rothsoft/libressl-3.6.1/crypto/.libs/libcrypto.a >=20 > The compilation process is OK but when I tried to execute the test app = I receive a link error: > Error loading DLL: = /root/rothsoft/engines/postgreSQL/Linux/postgresql/libpq.so: undefined = symbol: GENERAL_NAME_free >=20 > GENERAL_NAME_free usually means that libcrypto is missed. >=20 > Any help would be really appreciated. >=20 > Please note that I also tried with: > -l:/root/rothsoft/libressl-3.6.1/ssl/.libs/libssl.a > -l:/root/rothsoft/libressl-3.6.1/crypto/.libs/libcrypto.a >=20 > Thanks, > Marco >=20 >=20 >> On 5 Dec 2022, at 14:10, ALBERTO CABELLO S=C3=81NCHEZ = wrote: >>=20 >>>> Hi all, >>>>=20 >>>> After several attempts, I am asking for help with how to compile = libpq with OpenSSL >>>> statically linked. >>>> I need to have libpq linked with LibreSSL, but if I could = statically link OpenSSL, I think >>>> I could switch the TLS libraries at compile time. >>>=20 >>> redo the step which creates libpq.so appending your libssl.a = location >>> (mine is /usr/lib/x86_64-linux-gnu/libssl.a) at the end. >>=20 >> Just wanted to correct: you also have to remove "-lssl". So I guess = you can just >> substitute "-lssl" for libssl.a location in = src/interfaces/libpq/Makefile (two occurrences) >> and build as usual. >>=20 >=20 >=20 >=20