Skip to content

Commit f599291

Browse files
committedAug 27, 2018
Add explicit OpenSSL and LibreSSL from source travis targets
1 parent 18846f7 commit f599291

File tree

3 files changed

+208
-0
lines changed

3 files changed

+208
-0
lines changed
 

‎.travis.yml

+45
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,58 @@ matrix:
44
include:
55
- os: linux
66
compiler: gcc
7+
env: SSL=ubuntu EVENT=ubuntu
78
before_install:
89
- sudo apt-get install -qq libssl-dev libevent-dev check
910
- os: linux
1011
compiler: clang
12+
env: SSL=ubuntu EVENT=ubuntu
1113
before_install:
1214
- sudo apt-get install -qq libssl-dev libevent-dev check
15+
- os: linux
16+
compiler: clang
17+
env: SSL=openssl-1.0.2p EVENT=libevent-2.0.22
18+
cache:
19+
directories:
20+
- $HOME/opt
21+
before_install:
22+
- sudo apt-get install -qq check
23+
install:
24+
- ./Mk/bin/install-opt.sh
25+
before_script:
26+
- export OPENSSL_BASE="$HOME/opt/$SSL"
27+
- export LIBEVENT_BASE="$HOME/opt/$EVENT"
28+
- export LD_LIBRARY_PATH="$HOME/opt/$SSL/lib":"$HOME/opt/$EVENT/lib"
29+
- os: linux
30+
compiler: clang
31+
env: SSL=openssl-1.1.0i EVENT=libevent-2.1.8
32+
cache:
33+
directories:
34+
- $HOME/opt
35+
before_install:
36+
- sudo apt-get install -qq check
37+
install:
38+
- ./Mk/bin/install-opt.sh
39+
before_script:
40+
- export OPENSSL_BASE="$HOME/opt/$SSL"
41+
- export LIBEVENT_BASE="$HOME/opt/$EVENT"
42+
- export LD_LIBRARY_PATH="$HOME/opt/$SSL/lib":"$HOME/opt/$EVENT/lib"
43+
- os: linux
44+
compiler: clang
45+
env: SSL=libressl-2.7.4 EVENT=libevent-2.1.8
46+
cache:
47+
directories:
48+
- $HOME/opt
49+
before_install:
50+
- sudo apt-get install -qq check
51+
install:
52+
- ./Mk/bin/install-opt.sh
53+
before_script:
54+
- export OPENSSL_BASE="$HOME/opt/$SSL"
55+
- export LIBEVENT_BASE="$HOME/opt/$EVENT"
56+
- export LD_LIBRARY_PATH="$HOME/opt/$SSL/lib":"$HOME/opt/$EVENT/lib"
1357
- os: osx
58+
env: SSL=homebrew EVENT=homebrew
1459
before_install:
1560
- brew install openssl
1661
- brew install libevent

‎Mk/bin/install-opt.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
if [ -z "$SSL" ]; then
3+
echo '$SSL not set, aborting' >&2
4+
exit 1
5+
fi
6+
if [ -z "$EVENT" ]; then
7+
echo '$EVENT not set, aborting' >&2
8+
exit 1
9+
fi
10+
11+
case "$SSL" in
12+
openssl-*)
13+
SSLURL=https://www.openssl.org/source/$SSL.tar.gz
14+
;;
15+
libressl-*)
16+
#SSLURL=https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/$SSL.tar.gz
17+
SSLURL=http://ftp.fau.de/pub/OpenBSD/LibreSSL/$SSL.tar.gz
18+
;;
19+
*)
20+
exit 1
21+
;;
22+
esac
23+
24+
case "$EVENT" in
25+
libevent-2.1.8)
26+
EVENTURL=https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
27+
EVENTPATCH=Mk/patches/libevent-2.1.8.diff
28+
;;
29+
libevent-2.0.22)
30+
EVENTURL=https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
31+
;;
32+
*)
33+
exit 1
34+
;;
35+
esac
36+
37+
if [ ! -d "$HOME/opt/$SSL" ]; then
38+
wget "$SSLURL" || exit 1
39+
tar -xzvf "$SSL.tar.gz" || exit 1
40+
cd "$SSL" || exit 1
41+
./config shared --prefix="$HOME/opt/$SSL" || exit 1
42+
make && make install || { rm -rf "$HOME/opt/$SSL"; exit 1; }
43+
cd ..
44+
fi
45+
46+
export CPPFLAGS="-I$HOME/opt/$SSL/include"
47+
export LDFLAGS="-L$HOME/opt/$SSL/lib"
48+
49+
if [ ! -d "$HOME/opt/$EVENT" ]; then
50+
wget "$EVENTURL" || exit 1
51+
tar -xzvf "$EVENT-stable.tar.gz" || exit 1
52+
cd "$EVENT-stable" || exit 1
53+
if [ -n "$EVENTPATCH" ]; then
54+
patch -p0 < ../$EVENTPATCH || exit 1
55+
fi
56+
./configure --prefix="$HOME/opt/$EVENT" || exit 1
57+
make && make install || { rm -rf "$HOME/opt/$EVENT"; exit 1; }
58+
cd ..
59+
fi
60+

‎Mk/patches/libevent-2.1.8.diff

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
From 28b8075400c70b2d2da2ce07e590c2ec6d11783d Mon Sep 17 00:00:00 2001
2+
From: Bernard Spil <brnrd@FreeBSD.org>
3+
Date: Mon, 2 Apr 2018 13:18:27 +0200
4+
Subject: [PATCH] Fix build with LibreSSL 2.7
5+
6+
LibreSSL 2.7 implements OpenSSL 1.1 API except for BIO_get_init()
7+
8+
See also: https://bugs.freebsd.org/226900
9+
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
10+
Closes: #617 (cherry-pick)
11+
--- openssl-compat.h.orig 2017-01-25 23:37:15 UTC
12+
+++ openssl-compat.h
13+
@@ -1,7 +1,8 @@
14+
#ifndef OPENSSL_COMPAT_H
15+
#define OPENSSL_COMPAT_H
16+
17+
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
18+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
19+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
20+
21+
static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
22+
{
23+
@@ -30,6 +31,11 @@ static inline BIO_METHOD *BIO_meth_new(i
24+
25+
#define TLS_method SSLv23_method
26+
27+
-#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
28+
+#endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
29+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */
30+
+
31+
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L
32+
+#define BIO_get_init(b) (b)->init
33+
+#endif
34+
35+
#endif /* OPENSSL_COMPAT_H */
36+
--- sample/https-client.c.orig 2017-01-25 23:37:15 UTC
37+
+++ sample/https-client.c
38+
@@ -312,7 +312,8 @@ main(int argc, char **argv)
39+
}
40+
uri[sizeof(uri) - 1] = '\0';
41+
42+
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
43+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
44+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
45+
// Initialize OpenSSL
46+
SSL_library_init();
47+
ERR_load_crypto_strings();
48+
@@ -480,7 +481,8 @@ cleanup:
49+
SSL_CTX_free(ssl_ctx);
50+
if (type == HTTP && ssl)
51+
SSL_free(ssl);
52+
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
53+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
54+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
55+
EVP_cleanup();
56+
ERR_free_strings();
57+
58+
@@ -492,7 +494,8 @@ cleanup:
59+
CRYPTO_cleanup_all_ex_data();
60+
61+
sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
62+
-#endif /*OPENSSL_VERSION_NUMBER < 0x10100000L */
63+
+#endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
64+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */
65+
66+
#ifdef _WIN32
67+
WSACleanup();
68+
--- sample/le-proxy.c.orig 2017-01-25 23:37:15 UTC
69+
+++ sample/le-proxy.c
70+
@@ -259,7 +259,8 @@ main(int argc, char **argv)
71+
72+
if (use_ssl) {
73+
int r;
74+
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
75+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
76+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
77+
SSL_library_init();
78+
ERR_load_crypto_strings();
79+
SSL_load_error_strings();
80+
--- sample/openssl_hostname_validation.c.orig 2017-01-25 23:37:15 UTC
81+
+++ sample/openssl_hostname_validation.c
82+
@@ -48,7 +48,8 @@ SOFTWARE.
83+
84+
#define HOSTNAME_MAX_SIZE 255
85+
86+
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
87+
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
88+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
89+
#define ASN1_STRING_get0_data ASN1_STRING_data
90+
#endif
91+
92+
--- test/regress_ssl.c.orig 2017-01-25 23:37:15 UTC
93+
+++ test/regress_ssl.c
94+
@@ -186,7 +186,8 @@ get_ssl_ctx(void)
95+
void
96+
init_ssl(void)
97+
{
98+
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
99+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
100+
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
101+
SSL_library_init();
102+
ERR_load_crypto_strings();
103+
SSL_load_error_strings();

0 commit comments

Comments
 (0)
Please sign in to comment.