Skip to content

Commit

Permalink
Check a OpenSSL library directory existence.
Browse files Browse the repository at this point in the history
Add a logic to check a OpenSSL library directory existence on the given
`--with-openssl-dir=<dir>` option.

OpenSSL creates the library directory to the `/path/to/openssl_dir/lib64`
as a default, when it is built from the source as follow.

OpenSSL
```
$ ./Configure \
  --prefix=/path/to/openssl
$ make
$ make install
```

In the case of the following command, the `dir_config("openssl")` returns
`["/path/to/openssl/include", "/path/to/openssl/lib"]`. And this causes the
Ruby OpenSSL binding is unintentionally built with the system OpenSSL's library
directory, because the `/path/to/openssl/lib` doesn't exist. The logic to check
the OpenSSL library directory's existence is to avoid building in this case.

ruby/openssl
```
$ bundle exec rake compile -- \
  --with-openssl-dir=/path/to/openssl
```

In the case of the following command, the `dir_config("openssl")` returns
`["/path/to/openssl/include",
"/path/to/openssl/lib64:/path/to/openssl/lib64:/path/to/openssl/lib"]`.
The returned library directory string is a set of the directories with the path
separator ":".

```
$ bundle exec rake compile -- \
  --with-openssl-dir=/path/to/openssl \
  --with-openssl-lib=/path/to/openssl/lib64
```
  • Loading branch information
junaruga committed May 3, 2023
1 parent 037c181 commit 94da3c0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@

require "mkmf"

dir_config_given = dir_config("openssl").any?
openssl_dirs = dir_config("openssl")
dir_config_given = openssl_dirs.any?

_, ldir = openssl_dirs
if ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
raise "OpenSSL library directory could not be found in '#{ldir}'. " \
'You might want to use --with-openssl-lib=<dir> option to specify the ' \
'directory.'
end

dir_config("kerberos")

Logging::message "=== OpenSSL for Ruby configurator ===\n"
Expand Down

0 comments on commit 94da3c0

Please sign in to comment.