Skip to content

Commit 58a6953

Browse files
authored
Merge pull request #84 from martinRenou/patch_openssl
Patch OpenSSL for macos fix
2 parents 656d988 + dbfca64 commit 58a6953

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ set(XEUS_PYTHON_GIT_TAG 0.13.2)
3535

3636
configure_file(External_OpenSSL.cmake.in OpenSSL-download/CMakeLists.txt @ONLY)
3737
configure_file(bcryptgen.patch.in OpenSSL-download/bcryptgen.patch @ONLY)
38+
configure_file(commoncrypto.patch.in OpenSSL-download/commoncrypto.patch @ONLY)
3839
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
3940
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} .
4041
RESULT_VARIABLE result

External_OpenSSL.cmake.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (WIN32)
2727
set(OPENSSL_POSTINSTALL_CRYPTO_COMMAND ${CMAKE_COMMAND} -E copy libcrypto_static.lib ${EP_INSTALL_DIR}/lib/libcrypto_static.lib)
2828
set(OPENSSL_POSTINSTALL_SSL_COMMAND ${CMAKE_COMMAND} -E copy libssl_static.lib ${EP_INSTALL_DIR}/lib/libssl_static.lib)
2929
else()
30-
set(OPENSSL_PATCH_COMMAND "")
30+
set(OPENSSL_PATCH_COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/commoncrypto.patch)
3131
set(OPENSSL_CONFIG_COMMAND CFLAGS=-fPIC ./config --prefix=${EP_INSTALL_DIR})
3232
set(OPENSSL_BUILD_COMMAND make -j ${CPU_COUNT})
3333
if(APPLE)

commoncrypto.patch.in

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 96ac8f13f4d0ee96baf5724d9f96c44c34b8606c Mon Sep 17 00:00:00 2001
2+
From: David Carlier <[email protected]>
3+
Date: Tue, 24 Aug 2021 22:40:14 +0100
4+
Subject: [PATCH] Darwin platform allows to build on releases before
5+
Yosemite/ios 8.
6+
7+
issue #16407 #16408
8+
9+
Reviewed-by: Paul Dale <[email protected]>
10+
Reviewed-by: Tomas Mraz <[email protected]>
11+
(Merged from https://github.com/openssl/openssl/pull/16409)
12+
---
13+
crypto/rand/rand_unix.c | 5 +----
14+
include/crypto/rand.h | 10 ++++++++++
15+
2 files changed, 11 insertions(+), 4 deletions(-)
16+
17+
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
18+
index 43f1069d151d..0f4525106af7 100644
19+
--- a/crypto/rand/rand_unix.c
20+
+++ b/crypto/rand/rand_unix.c
21+
@@ -34,9 +34,6 @@
22+
#if defined(__OpenBSD__)
23+
# include <sys/param.h>
24+
#endif
25+
-#if defined(__APPLE__)
26+
-# include <CommonCrypto/CommonRandom.h>
27+
-#endif
28+
29+
#if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
30+
# include <sys/types.h>
31+
@@ -381,7 +378,7 @@ static ssize_t syscall_random(void *buf, size_t buflen)
32+
if (errno != ENOSYS)
33+
return -1;
34+
}
35+
-# elif defined(__APPLE__)
36+
+# elif defined(OPENSSL_APPLE_CRYPTO_RANDOM)
37+
if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
38+
return (ssize_t)buflen;
39+
40+
diff --git a/include/crypto/rand.h b/include/crypto/rand.h
41+
index 5350d3a93119..674f840fd13c 100644
42+
--- a/include/crypto/rand.h
43+
+++ b/include/crypto/rand.h
44+
@@ -20,6 +20,16 @@
45+
46+
# include <openssl/rand.h>
47+
48+
+# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM)
49+
+# include <Availability.h>
50+
+# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || \
51+
+ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000)
52+
+# define OPENSSL_APPLE_CRYPTO_RANDOM 1
53+
+# include <CommonCrypto/CommonCryptoError.h>
54+
+# include <CommonCrypto/CommonRandom.h>
55+
+# endif
56+
+# endif
57+
+
58+
/* forward declaration */
59+
typedef struct rand_pool_st RAND_POOL;
60+

0 commit comments

Comments
 (0)