Skip to content

Commit ee22140

Browse files
committed
ffi: don't dlopen extra libraries
On macOS the library load is handled in a specific and incompatible way, which is handled by the extension. As the gem uses the extension elsewhere, taking a direct dependency on that, and looking up symbols from in-process should be safe and sufficient.
1 parent 9532693 commit ee22140

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/bitcoin/ffi/openssl.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
# encoding: ascii-8bit
22

3+
require 'openssl'
34
require 'ffi'
45

56
module Bitcoin
67
# autoload when you need to re-generate a public_key from only its private_key.
78
# ported from: https://github.com/sipa/bitcoin/blob/2d40fe4da9ea82af4b652b691a4185431d6e47a8/key.h
89
module OpenSSL_EC # rubocop:disable Naming/ClassAndModuleCamelCase
910
extend FFI::Library
10-
if FFI::Platform.windows?
11-
ffi_lib 'libeay32', 'ssleay32'
12-
else
13-
ffi_lib [
14-
FFI::CURRENT_PROCESS,
15-
'libssl.so.1.1.0', 'libssl.so.1.1',
16-
'libssl.so.1.0.0', 'libssl.so.10',
17-
'ssl'
18-
]
19-
end
11+
12+
# Use the library loaded by the extension require above.
13+
ffi_lib FFI::CURRENT_PROCESS
2014

2115
NID_secp256k1 = 714 # rubocop:disable Naming/ConstantName
2216
POINT_CONVERSION_COMPRESSED = 2

0 commit comments

Comments
 (0)