diff --git a/src/postgres_extension.cpp b/src/postgres_extension.cpp index bed08a61a..dbf18afe5 100644 --- a/src/postgres_extension.cpp +++ b/src/postgres_extension.cpp @@ -1,5 +1,7 @@ #define DUCKDB_BUILD_LOADABLE_EXTENSION #include "duckdb.hpp" +#include +#include #include "postgres_scanner.hpp" #include "postgres_storage.hpp" @@ -116,6 +118,12 @@ static std::string CreatePoolNote(const std::string &option) { } static void LoadInternal(ExtensionLoader &loader) { + // Prevent a race with OpenSSL init that manifests itself with + // the following message on the first connection attempt: + // "port 5432 failed: could not create SSL context: unknown option" + OPENSSL_init_crypto(0, nullptr); + OPENSSL_init_ssl(0, nullptr); + // Register the OAuth bearer token hook before any connections are made PostgresInitOAuthHook();