Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Postgres with OpenSSL and '--with-openssl' option

I tried installing Postgres with OpenSSL by doing

./configure --with-openssl

but I got an error saying

configure: error: header file openssl/ssl.h is required for OpenSSL

However, I do have OpenSSL installed. If I run openssl version I get this output

OpenSSL 0.9.8zh 14 Jan 2016

I came across this solution and tried doing

./configure --with-includes=/usr/local/ssl/include and it installed without any problems.

Can someone explain whats going on and the difference between the two configure versions?

like image 354
Brosef Avatar asked Sep 01 '16 23:09

Brosef


People also ask

How do I enable SSL in PostgreSQL?

With SSL support compiled in, the PostgreSQL server can be started with SSL enabled by setting the parameter ssl to on in postgresql. conf. The server will listen for both normal and SSL connections on the same TCP port, and will negotiate with any connecting client on whether to use SSL .

How do you check SSL is enabled or not in Postgres?

Check that SSL is enabled with psql -c 'show ssl'. b. If the value of ssl is set to on, you are running with SSL enabled. You can type exit.

What is SSL mode in PostgreSQL?

Amazon RDS supports Secure Socket Layer (SSL) encryption for PostgreSQL DB instances. Using SSL, you can encrypt a PostgreSQL connection between your applications and your PostgreSQL DB instances. By default, RDS for PostgreSQL uses and expects all clients to connect using SSL/TLS, but you can also require it.

How do I set up OpenSSL?

Go to Advanced > Environment Variable. Set OPENSSL_CONF and Path variables. Open the command prompt using 'Windows' + 'r' then type 'cmd' to open command prompt. Type openssl version command on CLI to ensure OpenSSL is installed and configured on your Windows machine.


1 Answers

Can someone explain whats going on and the difference between the two configure versions.

You can run ./configure --help to get a synopsis of arguments:

$ ./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

This simply enables OpenSSL in Postgres. It enables checking in Autoconf, like probing for symbols CRYPTO_new_ex_data and SSL_Library_init.

It also looks like configure defines #define USE_OPENSSL 1 which activates OpenSSL code paths:

$ 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

This probably did not enable OpenSSL. It simply added a path for headers that were not used during compilation. Use lddon Linux and otool -L on OS X to see if there are any OpenSSL dependencies.


You should probably use ./configure --with-openssl --with-includes=/usr/local/ssl/include --with-libraries=/usr/local/ssl/lib. You should probably add CFLAGS="-Wl,-rpath=/usr/local/ssl/lib to ensure proper runtime linking.

Also see Postgres Issue 14308: Postgres 9.5.4 does not configure against OpenSSL 1.1.0

like image 63
jww Avatar answered Oct 06 '22 14:10

jww