1#ifndef LIBFILEZILLA_TLS_PARAMS_HEADER
2#define LIBFILEZILLA_TLS_PARAMS_HEADER
51#include "basic_tls_params.hpp"
58template <
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) };
70template <
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) };
79template <
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) };
91template <
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>
92basic_tls_filepath<native_string>
95 return basic_tls_filepath<native_string>{ std::forward<T>(v) };
101template <
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) };
113template <
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,
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);
The namespace used by libfilezilla.
Definition apply.hpp:17
basic_tls_param_variant< std::string, native_string, std::string > tls_param
Acts as an instance of one of a tls_blob, tls_filepath or tls_pkcs11url.
Definition tls_params.hpp:134
std::wstring native_string
A string in the system's native character type and encoding. Note: This typedef changes depending on...
Definition string.hpp:36
basic_tls_pkcs11url< T > tls_pkcs11url(T &&v)
Creates a tls_pkcs11url object.
Definition tls_params.hpp:102
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
bool starts_with(String const &s, String const &beginning)
Tests whether the first string starts with the second string.
Definition string.hpp:759
basic_tls_filepath< T > tls_filepath(T &&v)
Creates a tls_filepath object.
Definition tls_params.hpp:80
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 tls_blob, tls_filepath or tls_pkcs11url.
Definition tls_params.hpp:120
basic_tls_blob< T > tls_blob(T &&v)
Creates a tls_blob object.
Definition tls_params.hpp:59
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:142
@ autodetect
The type will be detected automatically using an heuristic.
Definition tls_params.hpp:143
@ der
The provided data is in DER format.
Definition tls_params.hpp:145
@ pem
The provided data is in PEM format.
Definition tls_params.hpp:144
basic_tls_param_variant< std::string &, native_string const &, std::string const & > tls_param_ref
Acts as a lvalue reference to one of a tls_blob, tls_filepath or tls_pkcs11url.
Definition tls_params.hpp:127