Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 1 | SUMMARY = "Secure Socket Layer" |
| 2 | DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools." |
| 3 | HOMEPAGE = "http://www.openssl.org/" |
| 4 | BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html" |
| 5 | SECTION = "libs/network" |
| 6 | |
| 7 | LICENSE = "Apache-2.0" |
| 8 | LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=c75985e733726beaba57bc5253e96d04" |
| 9 | |
| 10 | SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \ |
| 11 | file://run-ptest \ |
| 12 | file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \ |
| 13 | file://afalg.patch \ |
| 14 | file://0001-Configure-do-not-tweak-mips-cflags.patch \ |
| 15 | " |
| 16 | |
| 17 | SRC_URI:append:class-nativesdk = " \ |
| 18 | file://environment.d-openssl.sh \ |
| 19 | " |
| 20 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 21 | SRC_URI[sha256sum] = "aa7d8d9bef71ad6525c55ba11e5f4397889ce49c2c9349dcea6d3e4f0b024a7a" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 22 | |
| 23 | inherit lib_package multilib_header multilib_script ptest perlnative |
| 24 | MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash" |
| 25 | |
| 26 | PACKAGECONFIG ?= "" |
| 27 | PACKAGECONFIG:class-native = "" |
| 28 | PACKAGECONFIG:class-nativesdk = "" |
| 29 | |
| 30 | PACKAGECONFIG[cryptodev-linux] = "enable-devcryptoeng,disable-devcryptoeng,cryptodev-linux,,cryptodev-module" |
| 31 | PACKAGECONFIG[no-tls1] = "no-tls1" |
| 32 | PACKAGECONFIG[no-tls1_1] = "no-tls1_1" |
| 33 | |
| 34 | B = "${WORKDIR}/build" |
| 35 | do_configure[cleandirs] = "${B}" |
| 36 | |
| 37 | #| ./libcrypto.so: undefined reference to `getcontext' |
| 38 | #| ./libcrypto.so: undefined reference to `setcontext' |
| 39 | #| ./libcrypto.so: undefined reference to `makecontext' |
| 40 | EXTRA_OECONF:append:libc-musl = " no-async" |
| 41 | EXTRA_OECONF:append:libc-musl:powerpc64 = " no-asm" |
| 42 | |
| 43 | # adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions |
| 44 | # (native versions can be built with newer glibc, but then relocated onto a system with older glibc) |
| 45 | EXTRA_OECONF:class-native = "--with-rand-seed=os,devrandom" |
| 46 | EXTRA_OECONF:class-nativesdk = "--with-rand-seed=os,devrandom" |
| 47 | |
| 48 | # Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate. |
| 49 | CFLAGS:append:class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin" |
| 50 | CFLAGS:append:class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin" |
| 51 | |
| 52 | # This allows disabling deprecated or undesirable crypto algorithms. |
| 53 | # The default is to trust upstream choices. |
| 54 | DEPRECATED_CRYPTO_FLAGS ?= "" |
| 55 | |
| 56 | do_configure () { |
| 57 | # When we upgrade glibc but not uninative we see obtuse failures in openssl. Make |
| 58 | # the issue really clear that perl isn't functional due to symbol mismatch issues. |
| 59 | cat <<- EOF > ${WORKDIR}/perltest |
| 60 | #!/usr/bin/env perl |
| 61 | use POSIX; |
| 62 | EOF |
| 63 | chmod a+x ${WORKDIR}/perltest |
| 64 | ${WORKDIR}/perltest |
| 65 | |
| 66 | os=${HOST_OS} |
| 67 | case $os in |
| 68 | linux-gnueabi |\ |
| 69 | linux-gnuspe |\ |
| 70 | linux-musleabi |\ |
| 71 | linux-muslspe |\ |
| 72 | linux-musl ) |
| 73 | os=linux |
| 74 | ;; |
| 75 | *) |
| 76 | ;; |
| 77 | esac |
| 78 | target="$os-${HOST_ARCH}" |
| 79 | case $target in |
| 80 | linux-arc) |
| 81 | target=linux-latomic |
| 82 | ;; |
| 83 | linux-arm*) |
| 84 | target=linux-armv4 |
| 85 | ;; |
| 86 | linux-aarch64*) |
| 87 | target=linux-aarch64 |
| 88 | ;; |
| 89 | linux-i?86 | linux-viac3) |
| 90 | target=linux-x86 |
| 91 | ;; |
| 92 | linux-gnux32-x86_64 | linux-muslx32-x86_64 ) |
| 93 | target=linux-x32 |
| 94 | ;; |
| 95 | linux-gnu64-x86_64) |
| 96 | target=linux-x86_64 |
| 97 | ;; |
| 98 | linux-mips | linux-mipsel) |
| 99 | # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags |
| 100 | target="linux-mips32 ${TARGET_CC_ARCH}" |
| 101 | ;; |
| 102 | linux-gnun32-mips*) |
| 103 | target=linux-mips64 |
| 104 | ;; |
| 105 | linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el) |
| 106 | target=linux64-mips64 |
| 107 | ;; |
| 108 | linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*) |
| 109 | target=linux-generic32 |
| 110 | ;; |
| 111 | linux-powerpc) |
| 112 | target=linux-ppc |
| 113 | ;; |
| 114 | linux-powerpc64) |
| 115 | target=linux-ppc64 |
| 116 | ;; |
| 117 | linux-powerpc64le) |
| 118 | target=linux-ppc64le |
| 119 | ;; |
| 120 | linux-riscv32) |
| 121 | target=linux-generic32 |
| 122 | ;; |
| 123 | linux-riscv64) |
| 124 | target=linux-generic64 |
| 125 | ;; |
| 126 | linux-sparc | linux-supersparc) |
| 127 | target=linux-sparcv9 |
| 128 | ;; |
| 129 | mingw32-x86_64) |
| 130 | target=mingw64 |
| 131 | ;; |
| 132 | esac |
| 133 | |
| 134 | useprefix=${prefix} |
| 135 | if [ "x$useprefix" = "x" ]; then |
| 136 | useprefix=/ |
| 137 | fi |
| 138 | # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the |
| 139 | # environment variables set by bitbake. Adjust the environment variables instead. |
| 140 | HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \ |
| 141 | perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} ${DEPRECATED_CRYPTO_FLAGS} --prefix=$useprefix --openssldir=${libdir}/ssl-3 --libdir=${libdir} $target |
| 142 | perl ${B}/configdata.pm --dump |
| 143 | } |
| 144 | |
| 145 | do_install () { |
| 146 | oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install |
| 147 | |
| 148 | oe_multilib_header openssl/opensslconf.h |
| 149 | oe_multilib_header openssl/configuration.h |
| 150 | |
| 151 | # Create SSL structure for packages such as ca-certificates which |
| 152 | # contain hard-coded paths to /etc/ssl. Debian does the same. |
| 153 | install -d ${D}${sysconfdir}/ssl |
| 154 | mv ${D}${libdir}/ssl-3/certs \ |
| 155 | ${D}${libdir}/ssl-3/private \ |
| 156 | ${D}${libdir}/ssl-3/openssl.cnf \ |
| 157 | ${D}${sysconfdir}/ssl/ |
| 158 | |
| 159 | # Although absolute symlinks would be OK for the target, they become |
| 160 | # invalid if native or nativesdk are relocated from sstate. |
| 161 | ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-3/certs |
| 162 | ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-3/private |
| 163 | ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-3/openssl.cnf |
| 164 | } |
| 165 | |
| 166 | do_install:append:class-native () { |
| 167 | create_wrapper ${D}${bindir}/openssl \ |
| 168 | OPENSSL_CONF=${libdir}/ssl-3/openssl.cnf \ |
| 169 | SSL_CERT_DIR=${libdir}/ssl-3/certs \ |
| 170 | SSL_CERT_FILE=${libdir}/ssl-3/cert.pem \ |
| 171 | OPENSSL_ENGINES=${libdir}/engines-3 \ |
| 172 | OPENSSL_MODULES=${libdir}/ossl-modules |
| 173 | } |
| 174 | |
| 175 | do_install:append:class-nativesdk () { |
| 176 | mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d |
| 177 | install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh |
| 178 | sed 's|/usr/lib/ssl/|/usr/lib/ssl-3/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh |
| 179 | } |
| 180 | |
| 181 | PTEST_BUILD_HOST_FILES += "configdata.pm" |
| 182 | PTEST_BUILD_HOST_PATTERN = "perl_version =" |
| 183 | do_install_ptest () { |
| 184 | install -d ${D}${PTEST_PATH}/test |
| 185 | install -m755 ${B}/test/p_test.so ${D}${PTEST_PATH}/test |
| 186 | install -m755 ${B}/test/provider_internal_test.cnf ${D}${PTEST_PATH}/test |
| 187 | |
| 188 | # Prune the build tree |
| 189 | rm -f ${B}/fuzz/*.* ${B}/test/*.* |
| 190 | |
| 191 | cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH} |
| 192 | sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/configdata.pm |
| 193 | cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH} |
| 194 | |
| 195 | # For test_shlibload |
| 196 | ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/ |
| 197 | ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/ |
| 198 | |
| 199 | install -d ${D}${PTEST_PATH}/apps |
| 200 | ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps |
| 201 | install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps |
| 202 | install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps |
| 203 | |
| 204 | install -d ${D}${PTEST_PATH}/engines |
| 205 | install -m755 ${B}/engines/dasync.so ${D}${PTEST_PATH}/engines |
| 206 | install -m755 ${B}/engines/loader_attic.so ${D}${PTEST_PATH}/engines |
| 207 | install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines |
| 208 | |
| 209 | install -d ${D}${PTEST_PATH}/providers |
| 210 | install -m755 ${B}/providers/legacy.so ${D}${PTEST_PATH}/providers |
| 211 | |
| 212 | install -d ${D}${PTEST_PATH}/Configurations |
| 213 | cp -rf ${S}/Configurations/* ${D}${PTEST_PATH}/Configurations/ |
| 214 | |
| 215 | # seems to be needed with perl 5.32.1 |
| 216 | install -d ${D}${PTEST_PATH}/util/perl/recipes |
| 217 | cp ${D}${PTEST_PATH}/test/recipes/tconversion.pl ${D}${PTEST_PATH}/util/perl/recipes/ |
| 218 | |
| 219 | sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/util/wrap.pl |
| 220 | } |
| 221 | |
| 222 | # Add the openssl.cnf file to the openssl-conf package. Make the libcrypto |
| 223 | # package RRECOMMENDS on this package. This will enable the configuration |
| 224 | # file to be installed for both the openssl-bin package and the libcrypto |
| 225 | # package since the openssl-bin package depends on the libcrypto package. |
| 226 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 227 | PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc ${PN}-ossl-module-legacy" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 228 | |
| 229 | FILES:libcrypto = "${libdir}/libcrypto${SOLIBS}" |
| 230 | FILES:libssl = "${libdir}/libssl${SOLIBS}" |
| 231 | FILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf \ |
| 232 | ${libdir}/ssl-3/openssl.cnf* \ |
| 233 | " |
| 234 | FILES:${PN}-engines = "${libdir}/engines-3" |
| 235 | # ${prefix} comes from what we pass into --prefix at configure time (which is used for INSTALLTOP) |
| 236 | FILES:${PN}-engines:append:mingw32:class-nativesdk = " ${prefix}${libdir}/engines-3" |
| 237 | FILES:${PN}-misc = "${libdir}/ssl-3/misc ${bindir}/c_rehash" |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 238 | FILES:${PN}-ossl-module-legacy = "${libdir}/ossl-modules/legacy.so" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 239 | FILES:${PN} =+ "${libdir}/ssl-3/* ${libdir}/ossl-modules/" |
| 240 | FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh" |
| 241 | |
| 242 | CONFFILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf" |
| 243 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 244 | RRECOMMENDS:libcrypto += "openssl-conf ${PN}-ossl-module-legacy" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 245 | RDEPENDS:${PN}-misc = "perl" |
| 246 | RDEPENDS:${PN}-ptest += "openssl-bin perl perl-modules bash sed" |
| 247 | |
| 248 | RDEPENDS:${PN}-bin += "openssl-conf" |
| 249 | |
| 250 | BBCLASSEXTEND = "native nativesdk" |
| 251 | |
| 252 | CVE_PRODUCT = "openssl:openssl" |
| 253 | |
| 254 | CVE_VERSION_SUFFIX = "alphabetical" |
| 255 | |
| 256 | # Only affects OpenSSL >= 1.1.1 in combination with Apache < 2.4.37 |
| 257 | # Apache in meta-webserver is already recent enough |
| 258 | CVE_CHECK_IGNORE += "CVE-2019-0190" |