11#include <promeki/config.h>
12#if PROMEKI_ENABLE_CORE
23PROMEKI_NAMESPACE_BEGIN
162 PROMEKI_DATATYPE(SslContext, DataTypeSslContext, 1)
165 using List = ::promeki::List<SslContext>;
189 static bool hasTlsSupport();
217 SslContext(
const SslContext &other);
220 SslContext &operator=(
const SslContext &other);
223 SslContext(SslContext &&other)
noexcept;
226 SslContext &operator=(SslContext &&other)
noexcept;
238 bool isValid()
const;
241 bool operator==(
const SslContext &other)
const {
return _d == other._d; }
244 bool operator!=(
const SslContext &other)
const {
return !(*
this == other); }
261 String toString()
const;
264 void setProtocol(SslProtocol protocol);
267 SslProtocol protocol()
const;
281 Error setCertificate(
const FilePath &file);
284 Error setCertificate(
const Buffer &certData);
292 Error setPrivateKey(
const FilePath &file,
const String &passphrase = String());
306 Error setPrivateKey(
const Buffer &keyData,
const String &passphrase = String());
317 Error setCaCertificates(
const FilePath &caFile);
320 Error setCaCertificates(
const Buffer &caData);
330 Error setSystemCaCertificates();
349 void setVerifyPeer(
bool enable);
352 bool verifyPeer()
const;
373 void setRequireClientCert(
bool require);
376 bool requireClientCert()
const;
379 void setVerifyDepth(
int depth);
382 int verifyDepth()
const;
385 bool hasCertificate()
const;
388 bool hasCaCertificates()
const;
401 void *nativeConfig()
const;
415 Error writeToStream(DataStream &s)
const;
425 template <u
int32_t V>
static Result<SslContext> readFromStream(DataStream &s);
434 mutable SharedPtr<Impl, false> _d;
442template <u
int32_t V>
inline Result<SslContext> SslContext::readFromStream(DataStream &) {
443 return Result<SslContext>(SslContext(), Error::NotSupported);