1 #ifndef LIBFILEZILLA_TLS_PARAMS_HEADER
2 #define LIBFILEZILLA_TLS_PARAMS_HEADER
51 #include "basic_tls_params.hpp"
58 template <
typename T, std::enable_if_t<std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::
string> || std::is_same_v<T, std::
string_view>>* =
nullptr>
61 return basic_tls_blob<T>{ std::forward<T>(v) };
70 template <
typename T, std::enable_if_t<!(std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::
string> || std::is_same_v<T, std::
string_view>) && std::is_constructible_v<std::
string, T>>* =
nullptr>
73 return basic_tls_blob<std::string>{ std::forward<T>(v) };
79 template <
typename T, std::enable_if_t<std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, native_
string>>* =
nullptr>
82 return basic_tls_filepath<T>{ std::forward<T>(v) };
91 template <
typename T, std::enable_if_t<!(std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, native_
string>) && std::is_constructible_v<native_
string, T>>* =
nullptr>
92 basic_tls_filepath<native_string>
95 return basic_tls_filepath<native_string>{ std::forward<T>(v) };
101 template <
typename T, std::enable_if_t<std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::
string>>* =
nullptr>
104 return basic_tls_pkcs11url<T>{ std::forward<T>(v) };
113 template <
typename T, std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::
string> && std::is_constructible_v<std::
string, T>>* =
nullptr>
116 return basic_tls_pkcs11url<std::string>{ std::forward<T>(v) };
121 std::string_view
const,
129 native_string
const &,
134 using tls_param = basic_tls_param_variant<
149 inline bool is_pem(std::string_view blob)
151 constexpr std::string_view delimiters{
" \n\r\t"};
152 constexpr std::string_view pem_begin{
"-----BEGIN"};
154 auto pos = blob.find_first_not_of(delimiters);
155 return pos != blob.npos &&
starts_with(blob.substr(pos), pem_begin);
basic_tls_filepath< T > tls_filepath(T &&v)
Creates a tls_filepath object.
Definition: tls_params.hpp:80
bool starts_with(String const &s, String const &beginning)
Tests whether the first string starts with the second string.
Definition: string.hpp:663
basic_tls_param_variant< std::string, native_string, std::string > tls_param
Acts as an instance of one of a fz::tls_blob, fz::tls_filepath or fz::tls_pkcs11url.
Definition: tls_params.hpp:138
tls_data_format
The encoding type of a fz::tls_blob or the file pointed to by a fz::tls_filepath. ...
Definition: tls_params.hpp:141
The provided data is in PEM format.
basic_tls_blob< T > tls_blob(T &&v)
Creates a tls_blob object.
Definition: tls_params.hpp:59
basic_tls_param_variant< std::string_view const, native_string const &, std::string const & > const_tls_param_ref
Acts as a const lvalue reference to one of a fz::tls_blob, fz::tls_filepath or fz::tls_pkcs11url.
Definition: tls_params.hpp:124
The provided data is in DER format.
std::wstring native_string
A string in the system's native character type and encoding. Note: This typedef changes depending on...
Definition: string.hpp:34
basic_tls_pkcs11url< T > tls_pkcs11url(T &&v)
Creates a tls_pkcs11url object.
Definition: tls_params.hpp:102
The namespace used by libfilezilla.
Definition: apply.hpp:17
The type will be detected automatically using an heuristic.
bool is_pem(std::string_view blob)
returns true if the blob is in PEM format. Uses a simple heuristic.
Definition: tls_params.hpp:149
basic_tls_param_variant< std::string &, native_string const &, std::string const & > tls_param_ref
Acts as a lvalue reference to one of a fz::tls_blob, fz::tls_filepath or fz::tls_pkcs11url.
Definition: tls_params.hpp:131