Created attachment 267734 [details] patch to handle error return from SSL_CTX_new When /etc/ssl/openssl.cnf cannot be parsed, SSL_CTX_new in common.c:1186 will return NULL, which will in turn cause a core dump later when SSL_CTX_set_mode attempts to access it. The attached patch prints out the error message from OpenSSL and returns -1
I'm unable to provoke a null return, but it doesn't hurt to check.
You can trigger a NULL return by commenting out one of the sections. In /etc/ssl/openssl.cnf you can comment out the openssl_init section and it will trigger the NULL return, because it is referenced above somewhere. I guess the same applies to any of the file's sections.
Here's output with and without the patch respectively: $ LD_LIBRARY_PATH=/usr/obj/usr/src/amd64.amd64/lib/libfetch fetch http://www.usb.org/developers/devclass_docs/HID1_11.pdf 105004DFE4250000:error:0700007C:configuration file routines:CONF_modules_load:openssl conf references missing section:/usr/src/crypto/openssl/crypto/conf/conf_mod.c:163:openssl_conf=openssl_init fetch: http://www.usb.org/developers/devclass_docs/HID1_11.pdf: Authentication error $ fetch http://www.usb.org/developers/devclass_docs/HID1_11.pdf Segmentation fault (core dumped)
The question is, what did you do to your openssl.cnf to provoke this? I tried an empty file, an unreadable file, and a readable file with various syntax errors, and none of them resulted in a null context.
In my openssl.cnf, due to some etcupdate issue, one section, openssl_init, was missing. This section is referenced by some line above: openssl_conf = openssl_init To fix my actual problem, I just added an empty openssl_init section. Literally just adding a line with [ openssl_init ] made it work. To trigger the error to check the patch, I just change this line to #[ openssl_init ] and I get a coredump
I emailed my openssl.cnf privately, I hope it helps.
Obviously not observed: https://docs.openssl.org/3.6/man3/SSL_CTX_new/#return-values
Created attachment 267822 [details] openssl.cnf which triggers the segfault openssl.cnf which causes the segmentation fault to happen. It's the one in /usr/src/crypto/openssl/apps/openssl.cnf with 2 lines commented out: #[openssl_init] #providers = provider_sect
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4e160c6197f75fda3d5d5997ce893087058cf718 commit 4e160c6197f75fda3d5d5997ce893087058cf718 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-07 14:24:40 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-07 14:24:40 +0000 libfetch: Check for failure to create SSL context * Drop the ssl_meth member, there is no reason to hang on to it. * Replace deprecated SSLv23_client_method() with TLS_client_method(). * Check the return value from SSL_CTX_new(). MFC after: 1 week PR: 292903 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55098 lib/libfetch/common.c | 10 +++++++--- lib/libfetch/common.h | 1 - 2 files changed, 7 insertions(+), 4 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d653f474e901b1d43657b8955247d1bbd1c3d248 commit d653f474e901b1d43657b8955247d1bbd1c3d248 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-07 14:24:40 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-11 13:54:39 +0000 libfetch: Check for failure to create SSL context * Drop the ssl_meth member, there is no reason to hang on to it. * Replace deprecated SSLv23_client_method() with TLS_client_method(). * Check the return value from SSL_CTX_new(). MFC after: 1 week PR: 292903 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55098 (cherry picked from commit 4e160c6197f75fda3d5d5997ce893087058cf718) lib/libfetch/common.c | 10 +++++++--- lib/libfetch/common.h | 1 - 2 files changed, 7 insertions(+), 4 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4781aeb5b9cb564a53fee8128f6827402deaf9df commit 4781aeb5b9cb564a53fee8128f6827402deaf9df Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-07 14:24:40 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-11 13:54:41 +0000 libfetch: Check for failure to create SSL context * Drop the ssl_meth member, there is no reason to hang on to it. * Replace deprecated SSLv23_client_method() with TLS_client_method(). * Check the return value from SSL_CTX_new(). MFC after: 1 week PR: 292903 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55098 (cherry picked from commit 4e160c6197f75fda3d5d5997ce893087058cf718) lib/libfetch/common.c | 10 +++++++--- lib/libfetch/common.h | 1 - 2 files changed, 7 insertions(+), 4 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=767f1ebcf75e85912b65f9a117c9ab4f76ce71c0 commit 767f1ebcf75e85912b65f9a117c9ab4f76ce71c0 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-07 14:24:40 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-11 13:54:33 +0000 libfetch: Check for failure to create SSL context * Drop the ssl_meth member, there is no reason to hang on to it. * Replace deprecated SSLv23_client_method() with TLS_client_method(). * Check the return value from SSL_CTX_new(). MFC after: 1 week PR: 292903 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55098 (cherry picked from commit 4e160c6197f75fda3d5d5997ce893087058cf718) lib/libfetch/common.c | 10 +++++++--- lib/libfetch/common.h | 1 - 2 files changed, 7 insertions(+), 4 deletions(-)
A commit in branch releng/14.4 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=53e0a1d1ff9b9a8bd27fa65e0f84ca95f0e41298 commit 53e0a1d1ff9b9a8bd27fa65e0f84ca95f0e41298 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-07 14:24:40 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2026-02-12 21:24:34 +0000 libfetch: Check for failure to create SSL context * Drop the ssl_meth member, there is no reason to hang on to it. * Replace deprecated SSLv23_client_method() with TLS_client_method(). * Check the return value from SSL_CTX_new(). Approved by: re (cperciva) MFC after: 1 week PR: 292903 Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55098 (cherry picked from commit 4e160c6197f75fda3d5d5997ce893087058cf718) (cherry picked from commit 4781aeb5b9cb564a53fee8128f6827402deaf9df) lib/libfetch/common.c | 10 +++++++--- lib/libfetch/common.h | 1 - 2 files changed, 7 insertions(+), 4 deletions(-)