인성장

[PostgreSQL] Could not load library ... /pgcrypto.so: undefined symbol: EVP_cast 본문

PostgreSQL/Error

[PostgreSQL] Could not load library ... /pgcrypto.so: undefined symbol: EVP_cast

인성장 2024. 11. 19. 17:10

Error Message

ERROR:  could not load library "/postgres/app/postgres/pgsql15/lib/pgcrypto.so": /postgres/app/postgres/pgsql15/lib/pgcrypto.so: undefined symbol: EVP_cast5_cbc

 
Linux 8.x에 PostgreSQL 15를 Source File Compile 형식으로 설치하고 확장 기능인 pgcrypto를 생성하려 할때 위와 같은 에러가 발생했습니다.
 
실제로 pgcrypto 디렉토리 내에서 make check 시에도 아래와 같이 Error가 발생하는 것을 확인할 수 있습니다.

$ cd /home/postgres/postgresql-15.3/contrib/pgcrypto
$ make check
...(생략)...
============== running regression test queries        ==============
test init                         ... FAILED       56 ms
test md5                          ... FAILED       49 ms
test sha1                         ... FAILED       42 ms
test hmac-md5                     ... FAILED       33 ms
test hmac-sha1                    ... FAILED       33 ms
test blowfish                     ... FAILED       48 ms
test rijndael                     ... FAILED       35 ms
test sha2                         ... FAILED       52 ms
test des                          ... FAILED       30 ms
test 3des                         ... FAILED       36 ms
test cast5                        ... FAILED       34 ms
test crypt-des                    ... FAILED       41 ms
test crypt-md5                    ... FAILED       42 ms
test crypt-blowfish               ... FAILED       56 ms
test crypt-xdes                   ... FAILED       40 ms
test pgp-armor                    ... FAILED       39 ms
test pgp-decrypt                  ... FAILED       60 ms
test pgp-encrypt                  ... FAILED       32 ms
test pgp-compression              ... FAILED       34 ms
test pgp-pubkey-decrypt           ... FAILED       47 ms
test pgp-pubkey-encrypt           ... FAILED       32 ms
test pgp-info                     ... FAILED       31 ms
============== shutting down postmaster               ==============

========================
 22 of 22 tests failed.
========================
...(생략)...

 
정확한 이유는 모르나, OPENSSL과 관련된 문제인것으로 예상됩니다. 이 문제는 15 이후 버전의 pgcrypto 기능을 설치하여 사용하려 할때 문제가 발생되는 것을 확인했습니다.
 
해결방법
PostgreSQL 14 버전 Source File 안에 있는 pgcrypto 디렉토리를 가져와서 컴파일 해주면 됩니다.

-- 14 version source file : 압축 해제
$ tar -zxvf postgresql-14.11.tar.gz

-- 15 version source file : pgcrypto 디렉토리 백업
$ mv postgresql-15.3/contrib/pgcrypto postgresql-15.3/contrib/pgcrypto_old

-- 14 version pgcrypto 디렉토리 압축
$ cd postgresql-14.11/contrib/
$ tar -zcvf pgcrypto14.tar.gz pgcrypto/

-- 압축파일 15 version 설치파일 contrib 디렉토리로 이동
$ mv pgcrypto14.tar.gz /home/postgres/postgresql-15.3/contrib/
$ cd /home/postgres/postgresql-15.3/contrib

-- 14 version pgcrypto 압축 해제 및 컴파일
$ tar -zxvf pgcrypto14.tar.gz
$ cd pgcrypto
$ make && make install

 
위 작업을 마치면, psql 내부에서 pgcrypto 확장기능 1.3 버전으로 정상적으로 extension이 생성되는것을 보실 수 있습니다.

$ psql
Timing is on.
psql (15.3)
Type "help" for help.

postgres=# create extension pgcrypto;
CREATE EXTENSION
Time: 60.262 ms
postgres=# \dx
                                            List of installed extensions
        Name        | Version |   Schema   |                              Description
--------------------+---------+------------+------------------------------------------------------------------------
 bloom              | 1.0     | public     | bloom access method - signature file based index
 dblink             | 1.2     | public     | connect to other PostgreSQL databases from within a database
 pg_stat_statements | 1.10    | public     | track planning and execution statistics of all SQL statements executed
 pgcrypto           | 1.3     | public     | cryptographic functions
 plpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis            | 3.4.2   | public     | PostGIS geometry and geography spatial types and functions
(6 rows)