Skip to content

freebsd: fix broken OpenSSL configuration - #530

Open
altruby wants to merge 1 commit into
postmodern:masterfrom
altruby:freebsd_openssl_fix
Open

altruby wants to merge 1 commit into
postmodern:masterfrom
altruby:freebsd_openssl_fix

Conversation

@altruby

@altruby altruby commented Oct 20, 2026 •

Copy link
Copy Markdown

About

Fixes #529

FreeBSD provides OpenSSL as part of its base
system and it is configured to use the certs
that are also provided as part of the base
system (/etc/ssl/cert.pem).

The 'openssl' package that ruby-install currently
uses does not ship any certs and after install a
simple HTTPS request will fail:

ruby -rnet/http -e 'p Net::HTTP.get_response(URI.parse("https://google.com"))'
/../4.0.0/net/protocol.rb:46:in 'OpenSSL::SSL::SSLSocket#connect_nonblock': SSL_connect
returned=1 errno=0 peeraddr=142.250.219.206:443 state=error: certificate verify failed
(unable to get local  issuer certificate) (OpenSSL::SSL::SSLError)
OpenSSL error queue reported 0 errors:

The 'ca_root_nss' package does provide certs, but
not in a location that the OpenSSL package will
look. It would require extra steps that are more
complicated than depending on the base system's
OpenSSL.

How I tested

This change was tested in isolation, on an empty
jail that is based on 16-CURRENT. This is the script I used,
and it might be useful for your own tests:

#!/bin/sh
set -ex
jobs=$(sysctl -n hw.ncpu)
dest="/tmp/ruby-install-2"

if [ "$(id -u)" != "0" ]; then
  echo "you must be root"
  exit 1
fi

##
# Bootstrap the jail
if [ ! -e "${dest}" ]; then
  bsdinstall jail ${dest}
fi

##
# Bootstrap ruby-install (inside the jail)
PREFIX=/usr/local DESTDIR=${dest} make install

##
# Boot the jail
jail -n ruby-install -c path=${dest} \
                        host.hostname=ruby-install \
                        ip4=inherit \
                        persist \
                        mount.devfs \
                        devfs_ruleset=4 \
                        exec.start="/bin/sh /etc/rc" \
                        exec.stop="/bin/sh /etc/rc.shutdown jail"

##
# Install what we need
pkg -j ruby-install install -y bash curl

##
# Compile and test
jexec -u root ruby-install ruby-install "ruby" "4.0.7" "-j" "${jobs}" "--prefix" "/usr/local"
jexec -u root ruby-install ruby -rnet/http -e 'p Net::HTTP.get_response(URI("https://ruby-lang.org"))'

##
# Cleanup
jail -r ruby-install

Comment thread share/ruby-install/ruby/functions.sh Outdated
)
fi
;;
pkg)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be needed.
It was copied from the code just above this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required on a default base install.
Removed it.

Fixes postmodern#529

FreeBSD provides OpenSSL as part of its base
system and it is configured to use the certs
that are also provided as part of the base
system (/etc/ssl/cert.pem).

The 'openssl' package that ruby-install currently
uses does not ship any certs and after install a
simple HTTPS request will fail:

```
ruby -rnet/http -e 'p Net::HTTP.get_response(URI.parse("https://google.com"))'
/../4.0.0/net/protocol.rb:46:in 'OpenSSL::SSL::SSLSocket#connect_nonblock': SSL_connect
returned=1 errno=0 peeraddr=142.250.219.206:443 state=error: certificate verify failed
(unable to get local  issuer certificate) (OpenSSL::SSL::SSLError)
OpenSSL error queue reported 0 errors:
```

The 'ca_root_nss' package does provide certs, but
not in a location that the OpenSSL package will
look. It would require extra steps that are more
complicated than depending on the base system's
OpenSSL.

This change was tested in isolation, on an empty
jail that is based on 16-CURRENT. This is the script
I used, and it might be useful for your own tests:

```sh
set -ex
jobs=$(sysctl -n hw.ncpu)

if [ "$(id -u)" != "0" ]; then
  echo "you must be root"
  exit 1
fi

if [ ! -e "/tmp/ruby-install" ]; then
  bsdinstall jail /tmp/ruby-install
fi

PREFIX=/usr/local DESTDIR=/tmp/ruby-install make install

jail -n ruby-install -c path=/tmp/ruby-install \
                        host.hostname=ruby-install \
                        ip4=inherit \
                        persist \
                        mount.devfs \
                        devfs_ruleset=4 \
                        exec.start="/bin/sh /etc/rc" \
                        exec.stop="/bin/sh /etc/rc.shutdown jail"

pkg -j ruby-install install -y bash curl

jexec -u root ruby-install ruby-install "ruby" "4.0.7" "-j" "${jobs}" "--prefix" "/usr/local"
jexec -u root ruby-install ruby -rnet/http -e 'p Net::HTTP.get_response(URI("https://ruby-lang.org"))'

jail -r ruby-install
```
@altruby
altruby force-pushed the freebsd_openssl_fix branch from 7a9e8e4 to e1ffea2 Compare October 20, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FreeBSD: ruby-install configures a broken SSL installation

1 participant