When a certificate is trusted by one tool and not by another, the two are often reading different CA stores. openssl version -d tells you where this OpenSSL looks.
Ask for the directory, or for everything at once:
openssl version -d
openssl version -a
On Debian and Ubuntu the first prints OPENSSLDIR: "/usr/lib/ssl", where openssl.cnf, certs and cert.pem are links into /etc/ssl. That cert.pem points at ca-certificates.crt, the trust store OpenSSL uses by default. Homebrew on macOS has its own folder under the Homebrew prefix. -a adds the build date, platform, compiler flags and the folder for modules such as providers.
I’d check this first when a script fails with unable to get local issuer certificate while a browser on the same machine is fine. Browsers often use their own trust store or the system keychain, so they can trust a CA that OpenSSL has never heard of.
macOS adds a twist: /usr/bin/openssl is LibreSSL, while a Homebrew openssl is the real OpenSSL, each with its own folder. Run which -a openssl to see which ones you have. To trust a homelab CA system wide on Debian or Ubuntu, do not drop files in OPENSSLDIR by hand; put the CA in /usr/local/share/ca-certificates and run update-ca-certificates.
Further reading: OpenSSL: openssl-version, Debian: update-ca-certificates