Skip to content

Latest commit

 

History

History
127 lines (103 loc) · 3.7 KB

File metadata and controls

127 lines (103 loc) · 3.7 KB

OpenSSL Library Fix Guide

Problem

You encountered this error during Docker build:

configure: error: library 'crypto' is required for OpenSSL

Root Cause

The error occurs when:

  1. OpenSSL development libraries are not properly installed
  2. OpenSSL libraries are not found in the expected locations
  3. Package conflicts prevent proper OpenSSL installation
  4. Missing pkg-config configuration for OpenSSL

Solutions Applied

Enhanced OpenSSL Installation

# Install OpenSSL development libraries with proper conflict resolution
RUN yum install -y openssl openssl-devel || \
    (yum remove -y openssl-snapsafe-libs 2>/dev/null || true) && \
    yum install -y openssl openssl-devel

OpenSSL Verification

# Verify OpenSSL installation
RUN openssl version && \
    ls -la /usr/lib64/libssl.so* /usr/lib64/libcrypto.so* && \
    pkg-config --exists openssl && echo "OpenSSL pkg-config OK" || echo "OpenSSL pkg-config missing"

Environment Variables

Added OpenSSL environment variables for proper linking:

ENV OPENSSL_ROOT_DIR=/usr
ENV OPENSSL_LIBRARIES=/usr/lib64
ENV OPENSSL_INCLUDE_DIR=/usr/include/openssl
ENV PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$PKG_CONFIG_PATH

PostgreSQL OpenSSL Linking

Enhanced PostgreSQL build with explicit OpenSSL linking:

&& LDFLAGS="-L/usr/lib64" CPPFLAGS="-I/usr/include/openssl" make -j $(nproc) --silent && make install

How It Works

Installation Strategy

  1. Primary: Install both openssl and openssl-devel packages
  2. Fallback: Remove conflicting openssl-snapsafe-libs if needed
  3. Retry: Reinstall OpenSSL packages after conflict resolution

Verification Steps

  1. Version Check: openssl version confirms OpenSSL is installed
  2. Library Check: Lists OpenSSL shared libraries
  3. Pkg-config Check: Verifies pkg-config can find OpenSSL

Environment Configuration

  • OPENSSL_ROOT_DIR: Points to OpenSSL installation root
  • OPENSSL_LIBRARIES: Points to OpenSSL library directory
  • OPENSSL_INCLUDE_DIR: Points to OpenSSL header directory
  • PKG_CONFIG_PATH: Includes OpenSSL pkg-config directory

Testing the Fix

Test OpenSSL Installation

docker run --rm public.ecr.aws/lambda/provided:al2 openssl version

Test Library Availability

docker run --rm public.ecr.aws/lambda/provided:al2 ls -la /usr/lib64/libssl.so* /usr/lib64/libcrypto.so*

Build the Image

docker buildx build --platform=linux/amd64 -f dockerfiles/Dockerfile -t test-gdal .

Alternative Solutions

Option 1: Use Different Base Image

If OpenSSL issues persist, consider using Amazon Linux 2023:

FROM public.ecr.aws/lambda/provided:al2023 AS builder

Option 2: Build OpenSSL from Source

For maximum compatibility:

RUN curl -L https://www.openssl.org/source/openssl-1.1.1w.tar.gz | tar zx && \
    cd openssl-1.1.1w && \
    ./config --prefix=/usr/local/openssl && \
    make && make install

Option 3: Use System OpenSSL

Ensure system OpenSSL is properly configured:

RUN yum install -y openssl11 openssl11-devel && \
    ln -sf /usr/lib64/openssl11 /usr/lib64/openssl

Verification Commands

Check OpenSSL Installation

openssl version
pkg-config --modversion openssl

Check Library Paths

ldconfig -p | grep ssl
find /usr -name "libssl.so*" -o -name "libcrypto.so*"

Test Linking

gcc -lssl -lcrypto -o test test.c

The OpenSSL library issues should now be resolved! The enhanced installation and environment configuration should provide proper OpenSSL support for all dependencies. 🚀