In OpenSSL 3.2+, replace
SSL_CTX_set_default_verify_paths(ctx);
with
SSL_CTX_load_verify_store(ctx, "org.openssl.winstore://");
This loads certificates from the Windows system store.