[CXX-863] Failing to compile when MONGOC_HAVE_SSL is defined Created: 14/Mar/16  Updated: 30/Mar/16  Resolved: 18/Mar/16

Status: Closed
Project: C++ Driver
Component/s: Build, Implementation
Affects Version/s: 3.0.0
Fix Version/s: 3.0.1

Type: Bug Priority: Blocker - P1
Reporter: Petr Messner Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CXX-864 Evergreen builds do not enable SSL Closed

 Description   

$ cmake -DCMAKE_BUILD_TYPE=Release  -DCMAKE_INSTALL_PREFIX=/usr/local  -DCMAKE_CXX_FLAGS=-DMONGOC_HAVE_SSL=1.. &&     make 

produces

[ 22%] Building CXX object src/mongocxx/CMakeFiles/mongocxx.dir/bulk_write.cpp.o
[ 22%] Building CXX object src/mongocxx/CMakeFiles/mongocxx.dir/client.cpp.o
In file included from /mongo-cxx-driver/src/mongocxx/client.cpp:26:0:
/mongo-cxx-driver/src/mongocxx/private/ssl.hpp: In function 'mongoc_ssl_opt_t mongocxx::v_noabi::options::make_ssl_opts(const mongocxx::v_noabi::options::ssl&)':
/mongo-cxx-driver/src/mongocxx/private/ssl.hpp:30:45: error: 'const value_type' has no member named 'c_str'
         out.pem_file = ssl_opts.pem_file()->c_str();
                                             ^
/mongo-cxx-driver/src/mongocxx/private/ssl.hpp:33:48: error: 'const value_type' has no member named 'c_str'
         out.pem_pwd = ssl_opts.pem_password()->c_str();
                                                ^
/mongo-cxx-driver/src/mongocxx/private/ssl.hpp:36:43: error: 'const value_type' has no member named 'c_str'
         out.ca_file = ssl_opts.ca_file()->c_str();
                                           ^
/mongo-cxx-driver/src/mongocxx/private/ssl.hpp:39:41: error: 'const value_type' has no member named 'c_str'
         out.ca_dir = ssl_opts.ca_dir()->c_str();
                                         ^
/mongo-cxx-driver/src/mongocxx/private/ssl.hpp:42:45: error: 'const value_type' has no member named 'c_str'
         out.crl_file = ssl_opts.crl_file()->c_str();
                                             ^
src/mongocxx/CMakeFiles/mongocxx.dir/build.make:86: recipe for target 'src/mongocxx/CMakeFiles/mongocxx.dir/client.cpp.o' failed



 Comments   
Comment by Githook User [ 18/Mar/16 ]

Author:

{u'username': u'messa', u'name': u'Petr Messner', u'email': u'petr.messner@gmail.com'}

Message: CXX-863 Fix c_str() -> terminated().data() in make_ssl_opts
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/fbc13bde8a5be53dce837e64b4150281275c8c05

Comment by Andrew Morrow (Inactive) [ 18/Mar/16 ]

https://github.com/mongodb/mongo-cxx-driver/pull/463

Comment by Andrew Morrow (Inactive) [ 14/Mar/16 ]

We actually have a ticket to make the SSL status in the C++ driver more configurable. Ideally, it would default to matching whatever the C driver was configured for, but could also be explicitly chosen as on or off. Selecting it as "on" when the C driver doesn't offer it would result in an error. See https://jira.mongodb.org/browse/CXX-778

Comment by Petr Messner [ 14/Mar/16 ]

OK, cool

BTW. what is the correct way to compile mongo-cxx-driver with SSL support? Maybe it could be added to the Quickstart Guide on Github Wiki?

I am currently using this when building cxx driver:

    cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DCMAKE_CXX_FLAGS=-DMONGOC_HAVE_SSL=1 \
        ..

Am I supposed to be passing MONGOC_HAVE_SSL to cmake like this (using -DCMAKE_CXX_FLAGS) or is there any cleaner way? Maybe SSL support should be autodetected like it is in C driver...

If I don't specify MONGOC_HAVE_SSL then client that tries to use SSL fails with an exception "SSL support not available".

Comment by Andrew Morrow (Inactive) [ 14/Mar/16 ]

I've filed CXX-863 so we don't make this mistake again.

Comment by Andrew Morrow (Inactive) [ 14/Mar/16 ]

Thanks for the bug report. It looks like our continuous integration builds for the driver did not have SSL enabled, so we failed to catch this.

I have a few logistical notes on the PR, but I'll mention those over there.

Comment by Petr Messner [ 14/Mar/16 ]

I've added pull request that fixes this for me: https://github.com/mongodb/mongo-cxx-driver/pull/463

Generated at Wed Feb 07 22:00:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.