MongoDB C driver gives strange error about OpenSSL while installing

763 views Asked by At

While I'm trying to install MongoDB C driver via CMake, at compilation process it gives error that says;

  • libmongoc-1.0.so.0.0.0: undefined reference to "OSSL_HTTP_parse_url"
  • libmongoc-1.0.so.0.0.0: undefined reference to "SSL_get1_peer_certificate"

I'm on Ubuntu 20.04 and my OpenSSL version is OpenSSL 1.1.1f which Ubuntu says latest. I followed directions on MongoDB's official C driver setup. If somehow my OpenSSL packages broken, how can I fix it?

When I try it with an Ubuntu 20.04 image from Docker and running it on a container, I can compile it fine with the same OpenSSL package.

2

There are 2 answers

0
Emre On BEST ANSWER

I don't know why exactly but executing cmake configuration part that is on the website (cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..) with sudo solved this. Maybe it made CMake to find the right version of OpenSSL. I didn't perform any update on OpenSSL.

2
CristiFati On

The general advice is: whenever possible, stick with the defaults (apt-get install libmongoc-1.0-0).

Not sure what / how you're trying to build, but according to [OpenSSL]: SSL_get1_peer_certificate (emphasis is mine):

SSL_get0_peer_certificate() and SSL_get1_peer_certificate() were added in 3.0.0. SSL_get_peer_certificate() was deprecated in 3.0.0.

Same thing about OSSL_HTTP_parse_url.

So, you need (newer) OpenSSL 3.0 (don't know why this isn't specified in the installation URL).
Most likely you'd have to build it yourself ([OpenSSL.Wiki]: Compilation and Installation) - make sure to set --prefix=%OPENSSL30_INSTALL_DIR% and pass it (%OPENSSL30_INSTALL_DIR%) to (libmongoc's) configure tool.