Concurrent OpenSSL versions woes

My machine has OpenSSL 1.1.1f and 3.0.7 installed concurrently in rather different locations - however the .so files are all in the same dir but under distinct names.
When I do find_package(OpenSSL) and no hints it finds 1.1.1, and printing all variables from the man page (OPENSSL_LIBRARIES, OPENSSL_SSL_LIBRARIES etc) points to this.
However, when linking it fails as it tries to link to SSL_get1_peer_certificate which is a 3.0 specific function not in my code, nor in the libssl.so file CMake specifically says it links to. This libssl.so file is a symlink to libssl.so.1.1.
I wonder what I can do more to understand the diff between the CMake result variables and the systems reality?
I can get eg 3.0.7 to work by setting some hints, so mostly just curious what else I can do to understand where 3.0.7 creeps in here.

Look for other find_package() calls that might have brought the include directory of OpenSSL 3.x.
Your issue looks like one of:
a) your build uses OpenSSL 3.x headers but links to 1.x
b) some other component you use has been built against v 3.x

Thanks for the reply. Turns out that if I did a
find /usr/ -type f -exec grep -H "SSL_get1_peer_certificate" {} \;
I found another header location that I must have made some mistake installing some things into (I think an ldconfig went wrong). But CMake never said it used that location, but obviously did, somewhere. No mention in the generator file or anything though.
Case closed.