Loading...
Searching...
No Matches
tls.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/tls-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/tls.hpp> // IWYU pragma: export
#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
#include <string>
#include <utility>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/string/view_or_value.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class tls {
public:
tls() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() tls(v1::tls v);
explicit operator v1::tls() const {
v1::tls ret;
if (_pem_file) {
ret.pem_file(std::string{_pem_file->view()});
}
if (_pem_password) {
ret.pem_password(std::string{_pem_password->view()});
}
if (_ca_file) {
ret.ca_file(std::string{_ca_file->view()});
}
if (_ca_dir) {
ret.ca_dir(std::string{_ca_dir->view()});
}
if (_crl_file) {
ret.crl_file(std::string{_crl_file->view()});
}
if (_allow_invalid_certificates) {
ret.allow_invalid_certificates(*_allow_invalid_certificates);
}
return ret;
}
tls& pem_file(bsoncxx::v_noabi::string::view_or_value pem_file) {
_pem_file = std::move(pem_file);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const& pem_file() const {
return _pem_file;
}
tls& pem_password(bsoncxx::v_noabi::string::view_or_value pem_password) {
_pem_password = std::move(pem_password);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const& pem_password() const {
return _pem_password;
}
tls& ca_file(bsoncxx::v_noabi::string::view_or_value ca_file) {
_ca_file = std::move(ca_file);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const& ca_file() const {
return _ca_file;
}
tls& ca_dir(bsoncxx::v_noabi::string::view_or_value ca_dir) {
_ca_dir = std::move(ca_dir);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const& ca_dir() const {
return _ca_dir;
}
tls& crl_file(bsoncxx::v_noabi::string::view_or_value crl_file) {
_crl_file = std::move(crl_file);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const& crl_file() const {
return _crl_file;
}
tls& allow_invalid_certificates(bool allow_invalid_certificates) {
_allow_invalid_certificates = std::move(allow_invalid_certificates);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bool> const& allow_invalid_certificates() const {
return _allow_invalid_certificates;
}
class internal;
private:
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _pem_file;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _pem_password;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _ca_file;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _ca_dir;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _crl_file;
bsoncxx::v_noabi::stdx::optional<bool> _allow_invalid_certificates;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::tls from_v1(v1::tls v) {
return {std::move(v)};
}
inline v1::tls to_v1(v_noabi::options::tls const& v) {
return v1::tls{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v_noabi::string::view_or_value
A view-or-value variant type for strings.
Definition view_or_value.hpp:41
mongocxx::options::tls::tls
tls()=default
Default initialization.
mongocxx::v1::tls
Options related to TLS configuration.
Definition tls.hpp:48
mongocxx::v1::tls::ca_file
tls & ca_file(std::string v)
Set the "ca_file" field.
mongocxx::v1::tls::allow_invalid_certificates
tls & allow_invalid_certificates(bool v)
Set the "weak_cert_validation" field.
mongocxx::v1::tls::crl_file
tls & crl_file(std::string v)
Set the "crl_file" field.
mongocxx::v1::tls::ca_dir
tls & ca_dir(std::string v)
Set the "ca_dir" field.
mongocxx::v1::tls::pem_file
tls & pem_file(std::string v)
Set the "pem_file" field.
mongocxx::v1::tls::pem_password
tls & pem_password(std::string v)
Set the "pem_pwd" field.
mongocxx::v_noabi::options::tls
Used by mongocxx::v_noabi::options::client::tls_opts.
Definition tls.hpp:39
mongocxx::v_noabi::options::tls::ca_dir
tls & ca_dir(bsoncxx::v_noabi::string::view_or_value ca_dir)
The path to the Certificate Authority directory.
Definition tls.hpp:168
mongocxx::v_noabi::options::tls::pem_file
tls & pem_file(bsoncxx::v_noabi::string::view_or_value pem_file)
The path to the .pem file containing a public key certificate and its associated private key.
Definition tls.hpp:95
mongocxx::v_noabi::options::tls::pem_file
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & pem_file() const
Retrieves the current path to the .pem file.
Definition tls.hpp:105
mongocxx::v_noabi::options::tls::allow_invalid_certificates
tls & allow_invalid_certificates(bool allow_invalid_certificates)
If true, the driver will not verify the server's CA file.
Definition tls.hpp:216
mongocxx::v_noabi::options::tls::pem_password
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & pem_password() const
Retrieves the current decryption pass phrase.
Definition tls.hpp:129
mongocxx::v_noabi::options::tls::crl_file
tls & crl_file(bsoncxx::v_noabi::string::view_or_value crl_file)
The path to the .pem file that contains revoked certificates.
Definition tls.hpp:192
mongocxx::v_noabi::options::tls::ca_file
tls & ca_file(bsoncxx::v_noabi::string::view_or_value ca_file)
The path to the .pem file that contains the root certificate chain from the Certificate Authority.
Definition tls.hpp:144
mongocxx::v_noabi::options::tls::ca_dir
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & ca_dir() const
Retrieves the current path to the CA directory.
Definition tls.hpp:178
mongocxx::v_noabi::options::tls::allow_invalid_certificates
bsoncxx::v_noabi::stdx::optional< bool > const & allow_invalid_certificates() const
Retrieves whether or not the driver will check the server's CA file.
Definition tls.hpp:226
mongocxx::v_noabi::options::tls::tls
tls()=default
Default initialization.
mongocxx::v_noabi::options::tls::ca_file
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & ca_file() const
Retrieves the current path to the CA file.
Definition tls.hpp:154
mongocxx::v_noabi::options::tls::pem_password
tls & pem_password(bsoncxx::v_noabi::string::view_or_value pem_password)
The pass phrase used to decrypt an encrypted PEM file.
Definition tls.hpp:119
mongocxx::v_noabi::options::tls::crl_file
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & crl_file() const
Retrieves the current path to the .pem file that contains revoked certificates.
Definition tls.hpp:202
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
view_or_value.hpp
Provides bsoncxx::v_noabi::string::view_or_value.
tls.hpp
Provides mongocxx::v1::tls.
optional.hpp
Provides std::optional-related polyfills for library API usage.
tls-fwd.hpp
Declares mongocxx::v_noabi::options::tls.