【问题标题】:Configuring Postgres with OpenSSL and '--with-openssl' option使用 OpenSSL 和“--with-openssl”选项配置 Postgres
【发布时间】:2017-01-09 23:25:16
【问题描述】:

我尝试使用 OpenSSL 安装 Postgres

./configure --with-openssl

但我收到一个错误提示

配置:错误:OpenSSL 需要头文件 openssl/ssl.h

但是,我确实安装了 OpenSSL。如果我运行 openssl version 我会得到这个输出

OpenSSL 0.9.8zh 2016 年 1 月 14 日

我遇到了this solution 并尝试做

./configure --with-includes=/usr/local/ssl/include 并且安装没有任何问题。

有人可以解释发生了什么以及两个配置版本之间的区别吗?

【问题讨论】:

  • 安装了 openssl 并不意味着安装了开发文件。 Linux 发行版将库拆分为单独的包,仅用于使用和开发,例如 libssl-dev 用于基于 debian 的系统上的 openssl。

标签: postgresql openssl autoconf


【解决方案1】:

有人可以解释发生了什么以及两个配置版本之间的区别。

您可以运行./configure --help 来获取参数概要:

$ ./configure --help | egrep -i '(ssl|includes)'
  --with-includes=DIRS    look for additional header files in DIRS
  --with-openssl          build with OpenSSL support

./configure --with-openssl

这只是在 Postgres 中启用 OpenSSL。它可以检查 Autoconf,例如探测符号 CRYPTO_new_ex_dataSSL_Library_init

configure 还定义了#define USE_OPENSSL 1,它激活了 OpenSSL 代码路径:

$ grep -IR OPENSSL * | grep '.c'
...
src/backend/postmaster/fork_process.c:#ifdef USE_OPENSSL
src/backend/postmaster/fork_process.c:#ifdef USE_OPENSSL
src/backend/utils/init/postinit.c:#ifdef USE_OPENSSL
src/backend/utils/init/postinit.c:#ifdef USE_OPENSSL
src/include/libpq/libpq-be.h:#ifdef USE_OPENSSL
src/include/libpq/libpq-be.h:#ifdef USE_OPENSSL
...

./configure --with-includes=/usr/local/ssl/include

这可能没有启用 OpenSSL。它只是为编译期间未使用的头文件添加了一个路径。在 Linux 上使用 ldd,在 OS X 上使用 otool -L 来查看是否存在任何 OpenSSL 依赖项。


您可能应该使用./configure --with-openssl --with-includes=/usr/local/ssl/include --with-libraries=/usr/local/ssl/lib。您可能应该添加CFLAGS="-Wl,-rpath=/usr/local/ssl/lib 以确保正确的运行时链接。

另见Postgres Issue 14308: Postgres 9.5.4 does not configure against OpenSSL 1.1.0

【讨论】:

  • 所以我按照安装文件中的说明安装了 OpenSSL。但是,我的/usr/local/ssl 目录不包含lib 文件夹或include 文件夹。
  • @Brosef - 如果您需要帮助在平台上构建和安装 OpenSSL,那么您应该问另一个问题。请说明平台(OS X?)。我几乎提供了 OpenSSL 和 Postgres 的配方,但这个问题并不适合配方,因为它适用于 Postgres/Autoconf 并且缺少平台。
  • 很抱歉给您带来了困惑。当我使用我的路径尝试您的解决方案时,我收到错误“配置:错误:OpenSSL 需要库 'ssl'”。我必须运行./configure --with-openssl --with-includes=/usr/local/include/openssl --with-libraries=/usr/local/lib。出于某种原因,我的 libinclude 不包含在 /usr/local/ssl 中,而是位于 /usr/local/lib/usr/local/include
  • 我一直忽略您在底部提供的链接。看来我也遇到了同样的问题。
  • @Brosef - 另见How to tell Autoconf “require symbol A or B” from LIB? 我不知道Autoconf(我仍然编写自己的makefile),所以我不知道如何继续。配置完成后,即可继续连接到 OpenSSL 1.1.0 的端口。只要 Postgres 不太聪明地使用 OpenSSL,这应该是相对轻松的。
【解决方案2】:

安装 OpenSSL-devel 它将为您提供所有依赖项。这对我有帮助。

在 CenotOS/Redhat 中

sudo yum install openssl-devel

【讨论】:

    猜你喜欢
    • 2021-12-24
    • 2018-12-10
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多