My project uses MySQL connector, which use OpenSSL as its dependency. I've integrate gRPC with my project using FetchContent, with OpenSSL installed in my system. But it still use BoringSSL.
3 Answers
Add these to your CMakeList.txt
set(gRPC_SSL_PROVIDER package)

- 135
- 2
- 10
-
4Alternatively you can add `-DgRPC_SSL_PROVIDER=package` as command-line parameter when calling `cmake`. That's the way gRPC describes for building the gRPC libs. This is the way to set additional options without modifications on sources. – Ian Aug 21 '20 at 13:54
gRPC offers two ways to get its dependencies: with add_subdirectory
(I'm not a big fan of this way), and with find_package
(that's my favorite).
As documented here:
# Providers for third-party dependencies (gRPC_*_PROVIDER properties):
# "module": build the dependency using sources from git submodule (under third_party)
# "package": use cmake's find_package functionality to locate a pre-installed dependency
So in order to use your own SSL library, the best way is to:
- Make sure gRPC uses
find_package
, with-DgRPC_SSL_PROVIDER=package
. - Make sure that your SSL library will be found by
find_package
. Either because it is installed system-wide, or by using-DCMAKE_PREFIX_PATH
to helpfind_package
find it.
Here is an example fetching and building gRPC and its dependencies from sources. Note this line in particular, where gRPC is instructed to use the "package" mode.
I would advise against adding set(gRPC_SSL_PROVIDER package)
to your CMakeLists.txt. This should not be a concern of your project's CMakeLists, hence it's better to pass it as a command (-DgRPC_SSL_PROVIDER=package
).

- 7,297
- 6
- 49
- 95
We use gRPC by compiling source code. There was an issue (application segfault) due to which it was needed to to disable boringSSL for gRPC and use OpenSSL installed on the system. There are many suggestions. But the one that worked for me is below.
cmake -DgRPC_SSL_PROVIDER=OpenSSL . && make && make install

- 1
- 1
-
This is wrong, see here: https://github.com/grpc/grpc/blob/master/CMakeLists.txt#L69-L71 It should be `-DgRPC_SSL_PROVIDER=module` or `-DgRPC_SSL_PROVIDER=package` – JonasVautherin Sep 05 '22 at 13:50