summaryrefslogtreecommitdiff
path: root/build_openssl.sh
blob: a0fe40504ee6a3623f9385acc325a14f38c72cd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -e
set -x
tarball="openssl-1.1.0h.tar.gz"
dest="${tarball%%.tar.gz}"
url="https://www.openssl.org/source/${tarball}"
prefix="/opt/openssl"


function pre()
{
    curl -LO "${url}"
    tar xf "${tarball}"
}


function get_system_cacert() {
  local paths=(
    /etc/ssl/cert.pem
    /etc/ssl/cacert.pem
    /etc/ssl/certs/cacert.pem
    /etc/ssl/certs/ca-bundle.crt
  )
  for bundle in "${paths[@]}"
  do
    if [[ -f $bundle ]]; then
        echo "$bundle"
        break
    fi
  done
}


function build()
{
    pre
    pushd "${dest}"
        export KERNEL_BITS=64
        export PATH="$prefix/bin:$PATH"
        export LDFLAGS="-Wl,-rpath=$prefix/lib"
        target="linux-x86_64"

        ./Configure \
            --prefix="$prefix" \
            --openssldir="ssl" \
            --libdir="lib" \
            ${LDFLAGS} \
            ${target} \
            enable-ec_nistp_64_gcc_128 \
            zlib-dynamic \
            shared \
            no-ssl3-method
        make
        make install MANDIR="$prefix/share/man" MANSUFFIX=ssl
    popd
    post
}

function post()
{
    bundle=$(get_system_cacert)
    install -D -m644 "$bundle" "$prefix/ssl/cert.pem"
    rm -rf "${dest}"
    rm -rf "${tarball}"
    echo "All done."
}

# Main
build