Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Mutex.h
Go to the documentation of this file.
1//
2// Mutex.h
3//
4// Library: Foundation
5// Package: Threading
6// Module: Mutex
7//
8// Definition of the Mutex and FastMutex classes.
9//
10// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Foundation_Mutex_INCLUDED
18#define Foundation_Mutex_INCLUDED
19
20
21#include "Poco/Foundation.h"
22#include "Poco/Exception.h"
23#include "Poco/ScopedLock.h"
24#include "Poco/Timestamp.h"
25
26#if __cplusplus >= 201103L
27 #ifndef POCO_HAVE_STD_ATOMICS
28 #define POCO_HAVE_STD_ATOMICS
29 #endif
30#endif
31
32#ifdef POCO_HAVE_STD_ATOMICS
33 #include <atomic>
34#endif
35
36
37#if defined(POCO_OS_FAMILY_WINDOWS)
38#if defined(_WIN32_WCE)
39#include "Poco/Mutex_WINCE.h"
40#else
41#include "Poco/Mutex_WIN32.h"
42#endif
43#elif defined(POCO_VXWORKS)
44#include "Poco/Mutex_VX.h"
45#else
46#include "Poco/Mutex_POSIX.h"
47#endif
48
49
50namespace Poco {
51
52
54 /// A Mutex (mutual exclusion) is a synchronization
55 /// mechanism used to control access to a shared resource
56 /// in a concurrent (multithreaded) scenario.
57 /// Mutexes are recursive, that is, the same mutex can be
58 /// locked multiple times by the same thread (but, of course,
59 /// not by other threads).
60 /// Using the ScopedLock class is the preferred way to automatically
61 /// lock and unlock a mutex.
62{
63public:
64 using ScopedLock = Poco::ScopedLock<Mutex>;
65
67 /// creates the Mutex.
68
70 /// destroys the Mutex.
71
72 void lock();
73 /// Locks the mutex. Blocks if the mutex
74 /// is held by another thread.
75
76 void lock(long milliseconds);
77 /// Locks the mutex. Blocks up to the given number of milliseconds
78 /// if the mutex is held by another thread. Throws a TimeoutException
79 /// if the mutex can not be locked within the given timeout.
80 ///
81 /// Performance Note: On most platforms (including Windows), this member function is
82 /// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
83 /// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
84
85 bool tryLock();
86 /// Tries to lock the mutex. Returns false immediately
87 /// if the mutex is already held by another thread.
88 /// Returns true if the mutex was successfully locked.
89
90 bool tryLock(long milliseconds);
91 /// Locks the mutex. Blocks up to the given number of milliseconds
92 /// if the mutex is held by another thread.
93 /// Returns true if the mutex was successfully locked.
94 ///
95 /// Performance Note: On most platforms (including Windows), this member function is
96 /// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
97 /// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
98
99 void unlock();
100 /// Unlocks the mutex so that it can be acquired by
101 /// other threads.
102
103private:
104 Mutex(const Mutex&);
105 Mutex& operator = (const Mutex&);
106};
107
108
110 /// A FastMutex (mutual exclusion) is similar to a Mutex.
111 /// Unlike a Mutex, however, a FastMutex is not recursive,
112 /// which means that a deadlock will occur if the same
113 /// thread tries to lock a mutex it has already locked again.
114 /// Locking a FastMutex is faster than locking a recursive Mutex.
115 /// Using the ScopedLock class is the preferred way to automatically
116 /// lock and unlock a mutex.
117{
118public:
119 using ScopedLock = Poco::ScopedLock<FastMutex>;
120
122 /// creates the Mutex.
123
125 /// destroys the Mutex.
126
127 void lock();
128 /// Locks the mutex. Blocks if the mutex
129 /// is held by another thread.
130
131 void lock(long milliseconds);
132 /// Locks the mutex. Blocks up to the given number of milliseconds
133 /// if the mutex is held by another thread. Throws a TimeoutException
134 /// if the mutex can not be locked within the given timeout.
135 ///
136 /// Performance Note: On most platforms (including Windows), this member function is
137 /// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
138 /// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
139
140 bool tryLock();
141 /// Tries to lock the mutex. Returns false immediately
142 /// if the mutex is already held by another thread.
143 /// Returns true if the mutex was successfully locked.
144
145 bool tryLock(long milliseconds);
146 /// Locks the mutex. Blocks up to the given number of milliseconds
147 /// if the mutex is held by another thread.
148 /// Returns true if the mutex was successfully locked.
149 ///
150 /// Performance Note: On most platforms (including Windows), this member function is
151 /// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
152 /// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
153
154 void unlock();
155 /// Unlocks the mutex so that it can be acquired by
156 /// other threads.
157
158private:
161};
162
163
164#ifdef POCO_HAVE_STD_ATOMICS
165
166class Foundation_API SpinlockMutex
167 /// A SpinlockMutex, implemented in terms of std::atomic_flag, as
168 /// busy-wait mutual exclusion.
169 ///
170 /// While in some cases (eg. locking small blocks of code)
171 /// busy-waiting may be an optimal solution, in many scenarios
172 /// spinlock may not be the right choice - it is up to the user to
173 /// choose the proper mutex type for their particular case.
174 ///
175 /// Works with the ScopedLock class.
176{
177public:
178 using ScopedLock = Poco::ScopedLock<SpinlockMutex>;
179
180 SpinlockMutex();
181 /// Creates the SpinlockMutex.
182
183 ~SpinlockMutex();
184 /// Destroys the SpinlockMutex.
185
186 void lock();
187 /// Locks the mutex. Blocks if the mutex
188 /// is held by another thread.
189
190 void lock(long milliseconds);
191 /// Locks the mutex. Blocks up to the given number of milliseconds
192 /// if the mutex is held by another thread. Throws a TimeoutException
193 /// if the mutex can not be locked within the given timeout.
194
195 bool tryLock();
196 /// Tries to lock the mutex. Returns immediately, false
197 /// if the mutex is already held by another thread, true
198 /// if the mutex was successfully locked.
199
200 bool tryLock(long milliseconds);
201 /// Locks the mutex. Blocks up to the given number of milliseconds
202 /// if the mutex is held by another thread.
203 /// Returns true if the mutex was successfully locked.
204
205 void unlock();
206 /// Unlocks the mutex so that it can be acquired by
207 /// other threads.
208
209private:
210 std::atomic_flag _flag = ATOMIC_FLAG_INIT;
211};
212
213#endif // POCO_HAVE_STD_ATOMICS
214
215
217 /// A NullMutex is an empty mutex implementation
218 /// which performs no locking at all. Useful in policy driven design
219 /// where the type of mutex used can be now a template parameter allowing the user to switch
220 /// between thread-safe and not thread-safe depending on his need
221 /// Works with the ScopedLock class
222{
223public:
224 using ScopedLock = Poco::ScopedLock<NullMutex>;
225
227 /// Creates the NullMutex.
228 {
229 }
230
232 /// Destroys the NullMutex.
233 {
234 }
235
236 void lock()
237 /// Does nothing.
238 {
239 }
240
241 void lock(long)
242 /// Does nothing.
243 {
244 }
245
246 bool tryLock()
247 /// Does nothing and always returns true.
248 {
249 return true;
250 }
251
252 bool tryLock(long)
253 /// Does nothing and always returns true.
254 {
255 return true;
256 }
257
258 void unlock()
259 /// Does nothing.
260 {
261 }
262};
263
264
265//
266// inlines
267//
268
269//
270// Mutex
271//
272
273inline void Mutex::lock()
274{
276}
277
278
279inline void Mutex::lock(long milliseconds)
280{
281 if (!tryLockImpl(milliseconds))
282 throw TimeoutException();
283}
284
285
286inline bool Mutex::tryLock()
287{
288 return tryLockImpl();
289}
290
291
292inline bool Mutex::tryLock(long milliseconds)
293{
294 return tryLockImpl(milliseconds);
295}
296
297
298inline void Mutex::unlock()
299{
301}
302
303
304//
305// FastMutex
306//
307
308inline void FastMutex::lock()
309{
311}
312
313
314inline void FastMutex::lock(long milliseconds)
315{
316 if (!tryLockImpl(milliseconds))
317 throw TimeoutException();
318}
319
320
321inline bool FastMutex::tryLock()
322{
323 return tryLockImpl();
324}
325
326
327inline bool FastMutex::tryLock(long milliseconds)
328{
329 return tryLockImpl(milliseconds);
330}
331
332
333inline void FastMutex::unlock()
334{
336}
337
338
339#ifdef POCO_HAVE_STD_ATOMICS
340
341//
342// SpinlockMutex
343//
344
345inline void SpinlockMutex::lock()
346{
347 while (_flag.test_and_set(std::memory_order_acquire));
348}
349
350
351inline void SpinlockMutex::lock(long milliseconds)
352{
353 Timestamp now;
354 Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
355 while (_flag.test_and_set(std::memory_order_acquire))
356 {
357 if (now.isElapsed(diff)) throw TimeoutException();
358 }
359}
360
361
362inline bool SpinlockMutex::tryLock()
363{
364 return !_flag.test_and_set(std::memory_order_acquire);
365}
366
367
368inline bool SpinlockMutex::tryLock(long milliseconds)
369{
370 Timestamp now;
371 Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
372 while (_flag.test_and_set(std::memory_order_acquire))
373 {
374 if (now.isElapsed(diff)) return false;
375 }
376 return true;
377}
378
379
380inline void SpinlockMutex::unlock()
381{
382 _flag.clear(std::memory_order_release);
383}
384
385#endif // POCO_HAVE_STD_ATOMICS
386
387
388} // namespace Poco
389
390
391#endif // Foundation_Mutex_INCLUDED
#define ARK_API
Definition Base.h:9
#define POCO_EXTERNAL_OPENSSL
Definition Config.h:189
#define POCO_NO_SOO
Definition Config.h:82
#define POCO_DO_JOIN2(X, Y)
Definition Foundation.h:134
#define POCO_DO_JOIN(X, Y)
Definition Foundation.h:133
#define Foundation_API
Definition Foundation.h:60
#define POCO_JOIN(X, Y)
Definition Foundation.h:132
#define POCO_HAVE_IPv6
Definition Net.h:64
#define Net_API
Definition Net.h:47
#define NetSSL_API
Definition NetSSL.h:48
#define POCO_OS_IRIX
Definition Platform.h:35
#define POCO_OS_TRU64
Definition Platform.h:30
#define POCO_OS_WINDOWS_NT
Definition Platform.h:43
#define POCO_OS_HPUX
Definition Platform.h:29
#define POCO_OS_CYGWIN
Definition Platform.h:39
#define POCO_OS_WINDOWS_CE
Definition Platform.h:44
#define POCO_UNUSED
Definition Platform.h:274
#define POCO_OS_VXWORKS
Definition Platform.h:38
#define POCO_OS_ANDROID
Definition Platform.h:41
#define POCO_OS_QNX
Definition Platform.h:37
#define POCO_OS_AIX
Definition Platform.h:28
#define POCO_OS_LINUX
Definition Platform.h:31
#define POCO_OS_SOLARIS
Definition Platform.h:36
#define POCO_ARCH_AMD64
Definition Platform.h:129
#define OPENSSL_VERSION_PREREQ(maj, min)
Definition Crypto.h:36
#define Crypto_API
Definition Crypto.h:82
RSAPaddingMode
The padding mode used for RSA public key encryption.
Definition Crypto.h:44
@ RSA_PADDING_PKCS1_OAEP
PKCS #1 v1.5 padding. This currently is the most widely used mode.
Definition Crypto.h:48
@ RSA_PADDING_NONE
Definition Crypto.h:52
@ RSA_PADDING_PKCS1
Definition Crypto.h:45
#define POCO_EXTERNAL_OPENSSL_SLPRO
Definition Crypto.h:24
#define poco_ntoh_32(x)
Definition SocketDefs.h:328
#define INADDR_NONE
Definition SocketDefs.h:291
#define INADDR_BROADCAST
Definition SocketDefs.h:299
#define INADDR_ANY
Definition SocketDefs.h:295
#define poco_ntoh_16(x)
Definition SocketDefs.h:326
#define INADDR_LOOPBACK
Definition SocketDefs.h:303
virtual std::unique_ptr< ArkApi::ICommands > & GetCommands()=0
std::mutex RequestMutex_
Definition Requests.cpp:47
void WriteRequest(std::function< void(bool, std::string)> callback, bool success, std::string result)
Definition Requests.cpp:73
std::string GetResponse(Poco::Net::HTTPClientSession *session, Poco::Net::HTTPResponse &response)
Definition Requests.cpp:107
Poco::Net::HTTPRequest ConstructRequest(const std::string &url, Poco::Net::HTTPClientSession *&session, const std::vector< std::string > &headers, const std::string &request_type)
Definition Requests.cpp:79
std::vector< RequestData > RequestsVec_
Definition Requests.cpp:46
Requests(Requests &&)=delete
ARK_API bool CreateGetRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, std::vector< std::string > headers={})
Creates an async GET Request that runs in another thread but calls the callback from the main thread.
Definition Requests.cpp:129
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::vector< std::string > &post_ids, const std::vector< std::string > &post_data, std::vector< std::string > headers={})
Creates an async POST Request that runs in another thread but calls the callback from the main thread...
Definition Requests.cpp:238
Requests & operator=(Requests &&)=delete
ARK_API bool CreateDeleteRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, std::vector< std::string > headers={})
Creates an async DELETE Request that runs in another thread but calls the callback from the main thre...
Definition Requests.cpp:292
Requests & operator=(const Requests &)=delete
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::string &post_data, std::vector< std::string > headers={})
Creates an async POST Request with application/x-www-form-urlencoded content type that runs in anothe...
Definition Requests.cpp:162
static ARK_API Requests & Get()
Definition Requests.cpp:67
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::string &post_data, const std::string &content_type, std::vector< std::string > headers={})
Creates an async POST Request that runs in another thread but calls the callback from the main thread...
Definition Requests.cpp:200
std::unique_ptr< impl > pimpl
Definition Requests.h:84
Requests(const Requests &)=delete
virtual void AddOnTickCallback(const FString &id, const std::function< void(float)> &callback)=0
Added function will be called every frame.
virtual bool RemoveOnTickCallback(const FString &id)=0
Removes a on-tick callback.
Definition Logger.h:9
static std::shared_ptr< spdlog::logger > & GetLog()
Definition Logger.h:22
static std::string what(const char *msg, const char *file, int line, const char *text=0)
static void bugcheck(const char *msg, const char *file, int line)
static void nullPointer(const char *ptr, const char *file, int line)
static void debugger(const char *msg, const char *file, int line)
static void debugger(const char *file, int line)
static void bugcheck(const char *file, int line)
static void assertion(const char *cond, const char *file, int line, const char *text=0)
static void unexpected(const char *file, int line)
static struct CRYPTO_dynlock_value * dynlockCreate(const char *file, int line)
static void uninitialize()
Initializes the OpenSSL machinery.
static void initialize()
Automatically shut down OpenSSL on exit.
~OpenSSLInitializer()
Automatically initialize OpenSSL on startup.
static void lock(int mode, int n, const char *file, int line)
static unsigned long id()
static Poco::AtomicCounter _rc
static void enableFIPSMode(bool enabled)
static Poco::FastMutex * _mutexes
static void dynlock(int mode, struct CRYPTO_dynlock_value *lock, const char *file, int line)
static bool isFIPSEnabled()
Shuts down the OpenSSL machinery.
static void dynlockDestroy(struct CRYPTO_dynlock_value *lock, const char *file, int line)
This class represents a X509 Certificate.
void swap(X509Certificate &cert)
Move assignment.
std::string subjectName(NID nid) const
Returns the certificate subject's distinguished name.
bool equals(const X509Certificate &otherCertificate) const
const X509 * certificate() const
Poco::DateTime expiresOn() const
Returns the date and time the certificate is valid from.
X509Certificate(X509 *pCert, bool shared)
std::string issuerName(NID nid) const
Returns the certificate issuer's distinguished name.
const std::string & subjectName() const
X509Certificate(const X509Certificate &cert)
const std::string & serialNumber() const
Returns the version of the certificate.
X509Certificate & operator=(const X509Certificate &cert)
Creates the certificate by moving another one.
X509 * dup() const
Returns the underlying OpenSSL certificate.
~X509Certificate()
Exchanges the certificate with another one.
bool issuedBy(const X509Certificate &issuerCertificate) const
const std::string & issuerName() const
long version() const
Destroys the X509Certificate.
X509Certificate(X509Certificate &&cert) noexcept
Creates the certificate by copying another one.
void load(std::istream &stream)
Writes the list of certificates to the specified PEM file.
std::string signatureAlgorithm() const
void print(std::ostream &out) const
Returns the certificate signature algorithm long name.
Poco::DateTime validFrom() const
X509Certificate(std::istream &istr)
std::string commonName() const
void save(std::ostream &stream) const
OpenSSLInitializer _openSSLInitializer
X509Certificate & operator=(X509Certificate &&cert) noexcept
Assigns a certificate.
std::string displayText() const
Returns the exception code if defined.
void unlock()
Definition Mutex.h:333
bool tryLock(long milliseconds)
Definition Mutex.h:327
~FastMutex()
creates the Mutex.
void lock()
destroys the Mutex.
Definition Mutex.h:308
bool tryLock()
Definition Mutex.h:321
FastMutex(const FastMutex &)
void lock(long milliseconds)
Definition Mutex.h:314
FastMutex & operator=(const FastMutex &)
bool tryLock(long milliseconds)
Definition Mutex.h:292
void lock(long milliseconds)
Definition Mutex.h:279
void unlock()
Definition Mutex.h:298
void lock()
destroys the Mutex.
Definition Mutex.h:273
Mutex & operator=(const Mutex &)
bool tryLock()
Definition Mutex.h:286
Mutex(const Mutex &)
~Mutex()
creates the Mutex.
bool tryLockImpl(long milliseconds)
void init(const Params &params)
void setSessionCacheSize(std::size_t size)
Returns true iff the session cache is enabled.
std::size_t getSessionCacheSize() const
Context::VerificationMode verificationMode() const
Returns true iff the context is for use by a server.
Definition Context.h:466
void requireMinimumProtocol(Protocols protocol)
void enableExtendedCertificateVerification(bool flag=true)
void setInvalidCertificateHandler(InvalidCertificateHandlerPtr pInvalidCertificageHandler)
Usage _usage
Create a SSL_CTX object according to Context configuration.
Definition Context.h:437
Usage usage() const
Returns the underlying OpenSSL SSL Context object.
Definition Context.h:449
SSL_CTX * sslContext() const
Definition Context.h:472
long getSessionTimeout() const
void usePrivateKey(const Poco::Crypto::RSAKey &key)
Add one trusted certification authority to be used by the Context.
void enableSessionCache(bool flag=true)
Returns the verification mode.
void addCertificateAuthority(const Poco::Crypto::X509Certificate &certificate)
Adds a certificate for certificate chain validation.
void usePrivateKey(const Poco::Crypto::EVPPKey &pkey)
bool extendedCertificateVerificationEnabled() const
Definition Context.h:478
bool isForServerUse() const
Definition Context.h:455
void addChainCertificate(const Poco::Crypto::X509Certificate &certificate)
bool _ocspStaplingResponseVerification
Definition Context.h:441
bool ocspStaplingResponseVerificationEnabled() const
Definition Context.h:484
bool _extendedCertificateVerification
Definition Context.h:440
VerificationMode _mode
Definition Context.h:438
@ SERVER_USE
DEPRECATED. Context is used by a client.
Definition Context.h:71
@ TLSV1_2_CLIENT_USE
DEPRECATED. Context is used by a server requiring TLSv1.1 (OpenSSL 1.0.0 or newer).
Definition Context.h:76
@ TLSV1_CLIENT_USE
DEPRECATED. Context is used by a server.
Definition Context.h:72
@ TLSV1_3_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.3 (OpenSSL 1.1.1 or newer).
Definition Context.h:79
@ CLIENT_USE
Context is used by a client for TLSv1 or higher. Use requireMinimumProtocol() or disableProtocols() t...
Definition Context.h:70
@ TLSV1_2_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.2 (OpenSSL 1.0.1 or newer).
Definition Context.h:77
@ TLSV1_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.
Definition Context.h:73
@ TLSV1_3_CLIENT_USE
DEPRECATED. Context is used by a server requiring TLSv1.2 (OpenSSL 1.0.1 or newer).
Definition Context.h:78
@ TLS_SERVER_USE
Context is used by a client for TLSv1 or higher. Use requireMinimumProtocol() or disableProtocols() t...
Definition Context.h:69
@ TLSV1_1_CLIENT_USE
DEPRECATED. Context is used by a server requiring TLSv1.
Definition Context.h:74
@ TLSV1_1_SERVER_USE
DEPRECATED. Context is used by a client requiring TLSv1.1 (OpenSSL 1.0.0 or newer).
Definition Context.h:75
void useCertificate(const Poco::Crypto::X509Certificate &certificate)
Destroys the Context.
void preferServerCiphers()
Context(Usage usage, const Params &params)
InvalidCertificateHandlerPtr _pInvalidCertificateHandler
Definition Context.h:442
void setSessionTimeout(long seconds)
InvalidCertificateHandlerPtr getInvalidCertificateHandler() const
Definition Context.h:490
void disableStatelessSessionResumption()
bool sessionCacheEnabled() const
void disableProtocols(int protocols)
SSL_CTX * _pSSLContext
Definition Context.h:439
virtual std::istream & receiveResponse(HTTPResponse &response)
virtual std::ostream & sendRequest(HTTPRequest &request)
Returns the connection timeout for HTTP connections.
static const std::string HTTP_1_1
void setContentLength(std::streamsize length)
Returns the HTTP version for this message.
HTTPRequest(const std::string &method, const std::string &uri, const std::string &version)
Creates a HTTP/1.0 request with the given method and URI.
static const std::string HTTP_GET
static const std::string HTTP_DELETE
static const std::string HTTP_POST
const std::string & getReason() const
Sets the HTTP reason phrase.
HTTPResponse(HTTPStatus status)
HTTPStatus getStatus() const
HTTPSClientSession(const std::string &host, Poco::UInt16 port, Context::Ptr pContext, Session::Ptr pSession)
std::string proxyRequestPrefix() const
Sends the given HTTPRequest over an existing connection.
HTTPSClientSession(Context::Ptr pContext, Session::Ptr pSession)
HTTPSClientSession(Context::Ptr pContext)
Creates a HTTPSClientSession using the given host and port.
void proxyAuthenticate(HTTPRequest &request)
Checks if we can reuse a persistent connection.
int read(char *buffer, std::streamsize length)
HTTPSClientSession(const HTTPSClientSession &)
void connect(const SocketAddress &address)
Refills the internal buffer.
HTTPSClientSession(const SecureStreamSocket &socket, Session::Ptr pSession)
X509Certificate serverCertificate()
HTTPSClientSession & operator=(const HTTPSClientSession &)
HTTPSClientSession(const std::string &host, Poco::UInt16 port=HTTPS_PORT)
HTTPSClientSession(const SecureStreamSocket &socket)
Creates an unconnected HTTPSClientSession.
HTTPSClientSession(const std::string &host, Poco::UInt16 port, Context::Ptr pContext)
InvalidCertificateHandler(bool handleErrorsOnServerSide)
virtual void onInvalidCertificate(const void *pSender, VerificationErrorArgs &errorCert)=0
Destroys the InvalidCertificateHandler.
RejectCertificateHandler(bool handleErrorsOnServerSide)
void initializeClient(PrivateKeyPassphraseHandlerPtr ptrPassphraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext)
static SSLManager & instance()
static std::string convertCertificateError(long errCode)
static std::string getLastError()
Converts an SSL certificate handling error code into an error message.
static void clearErrorStack()
Returns the last error from the error stack.
A utility class for certificate error handling.
void unlock()
Does nothing.
Definition Mutex.h:258
void lock(long)
Does nothing.
Definition Mutex.h:241
NullMutex()
Creates the NullMutex.
Definition Mutex.h:226
bool tryLock()
Does nothing and always returns true.
Definition Mutex.h:246
void lock()
Does nothing.
Definition Mutex.h:236
~NullMutex()
Destroys the NullMutex.
Definition Mutex.h:231
bool tryLock(long)
Does nothing and always returns true.
Definition Mutex.h:252
This stream discards all characters written to it.
Definition NullStream.h:77
static std::streamsize copyStream(std::istream &istr, std::ostream &ostr, std::size_t bufferSize=8192)
bool isElapsed(TimeDiff interval) const
Definition Timestamp.h:249
const std::string & getHost() const
Sets the user-info part of the URI.
Definition URI.h:385
const std::string & getScheme() const
Definition URI.h:373
URI(const std::string &uri)
Creates an empty URI.
unsigned short getPort() const
Sets the host part of the URI.
std::string getPathAndQuery() const
Returns the encoded path, query and fragment parts of the URI.
void error(const T &)
Definition IBaseApi.h:9
std::unique_ptr< IBaseApi > game_api
Definition IBaseApi.h:25
void Crypto_API uninitializeCrypto()
void Crypto_API initializeCrypto()
std::vector< SocketBuf > SocketBufVec
Definition SocketDefs.h:365
void NetSSL_API initializeSSL()
void Net_API uninitializeNetwork()
void Net_API initializeNetwork()
void NetSSL_API uninitializeSSL()
MutexImpl FastMutexImpl
Definition Mutex_WIN32.h:44
Definition format.h:408
Definition json.hpp:4518
#define OPENSSL_VERSION_NUMBER
Definition opensslv.h:42
struct ssl_ctx_st SSL_CTX
Definition ossl_typ.h:149
struct x509_st X509
Definition ossl_typ.h:121
#define SSL_VERIFY_NONE
Definition ssl.h:1099
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT
Definition ssl.h:1101
#define SSL_VERIFY_PEER
Definition ssl.h:1100
#define SSL_VERIFY_CLIENT_ONCE
Definition ssl.h:1102
std::function< void(bool, std::string)> callback
Definition Requests.cpp:41
Family
Possible address families for socket addresses.
Definition SocketDefs.h:373
std::string privateKeyFile
Initializes the struct with default values.
Definition Context.h:134
std::string certificateFile
Definition Context.h:138
VerificationMode verificationMode
Definition Context.h:149
static std::string escape(const std::string &s, bool strictJSON=false)