|
| 1 | +name: Build Custom OpenSSL |
| 2 | +description: Download, configure, and build OpenSSL from source with sanitizer flags |
| 3 | + |
| 4 | +inputs: |
| 5 | + openssl-version: |
| 6 | + description: OpenSSL version to build |
| 7 | + required: true |
| 8 | + install-prefix: |
| 9 | + description: Installation prefix path |
| 10 | + required: true |
| 11 | + sanitizer-flags: |
| 12 | + description: Sanitizer compiler/linker flags |
| 13 | + required: true |
| 14 | + cache-key: |
| 15 | + description: Cache key for this OpenSSL build |
| 16 | + required: true |
| 17 | + |
| 18 | +runs: |
| 19 | + using: composite |
| 20 | + steps: |
| 21 | + - name: Install OpenSSL build tools |
| 22 | + shell: bash |
| 23 | + run: | |
| 24 | + apt-get update |
| 25 | + apt-get install -y perl make curl |
| 26 | +
|
| 27 | + - name: Restore OpenSSL cache |
| 28 | + id: cache-openssl |
| 29 | + uses: actions/cache@v4 |
| 30 | + with: |
| 31 | + path: ${{ inputs.install-prefix }} |
| 32 | + key: ${{ inputs.cache-key }} |
| 33 | + |
| 34 | + - name: Build OpenSSL |
| 35 | + if: steps.cache-openssl.outputs.cache-hit != 'true' |
| 36 | + shell: bash |
| 37 | + env: |
| 38 | + CC: clang |
| 39 | + CXX: clang++ |
| 40 | + run: | |
| 41 | + set -euxo pipefail |
| 42 | + OPENSSL_VERSION="${{ inputs.openssl-version }}" |
| 43 | + OPENSSL_PREFIX="${{ inputs.install-prefix }}" |
| 44 | + SAN_FLAGS="${{ inputs.sanitizer-flags }}" |
| 45 | +
|
| 46 | + mkdir -p "$(dirname "$OPENSSL_PREFIX")" |
| 47 | + curl -fsSL "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \ |
| 48 | + -o "/tmp/openssl-${OPENSSL_VERSION}.tar.gz" |
| 49 | + tar -xzf "/tmp/openssl-${OPENSSL_VERSION}.tar.gz" -C /tmp |
| 50 | +
|
| 51 | + cd "/tmp/openssl-${OPENSSL_VERSION}" |
| 52 | + export CFLAGS="$SAN_FLAGS" |
| 53 | + export CXXFLAGS="$SAN_FLAGS" |
| 54 | + export LDFLAGS="$SAN_FLAGS" |
| 55 | + ./Configure linux-x86_64 no-shared no-tests no-module no-asm \ |
| 56 | + --prefix="$OPENSSL_PREFIX" \ |
| 57 | + --openssldir="$OPENSSL_PREFIX/ssl" |
| 58 | + make -j"$(nproc)" |
| 59 | + make install_sw |
0 commit comments