Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Context.h
Go to the documentation of this file.
1//
2// Context.h
3//
4// Library: NetSSL_OpenSSL
5// Package: SSLCore
6// Module: Context
7//
8// Definition of the Context class.
9//
10// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef NetSSL_Context_INCLUDED
18#define NetSSL_Context_INCLUDED
19
20
21#include "Poco/Net/NetSSL.h"
22#include "Poco/Net/SocketDefs.h"
23#include "Poco/Net/InvalidCertificateHandler.h"
24#include "Poco/Crypto/X509Certificate.h"
25#include "Poco/Crypto/EVPPKey.h"
26#include "Poco/Crypto/RSAKey.h"
27#include "Poco/RefCountedObject.h"
28#include "Poco/SharedPtr.h"
29#include "Poco/AutoPtr.h"
30#include <openssl/ssl.h>
31#include <cstdlib>
32
33
34namespace Poco {
35namespace Net {
36
37
39 /// This class encapsulates context information for
40 /// an SSL server or client, such as the certificate
41 /// verification mode and the location of certificates
42 /// and private key files, as well as the list of
43 /// supported ciphers.
44 ///
45 /// The Context class is also used to control
46 /// SSL session caching on the server and client side.
47 ///
48 /// A Note Regarding TLSv1.3 Support:
49 ///
50 /// TLSv1.3 support requires at least OpenSSL version 1.1.1.
51 /// Make sure that the TLSv1.3 cipher suites are enabled:
52 ///
53 /// - TLS_AES_256_GCM_SHA384
54 /// - TLS_CHACHA20_POLY1305_SHA256
55 /// - TLS_AES_128_GCM_SHA256
56 /// - TLS_AES_128_CCM_8_SHA256
57 /// - TLS_AES_128_CCM_SHA256
58 ///
59 /// The first three of the above cipher suites should be enabled
60 /// by default in OpenSSL if you do not provide an explicit
61 /// cipher configuration (cipherList).
62{
63public:
64 using Ptr = Poco::AutoPtr<Context>;
65
66 enum Usage
67 {
68 TLS_CLIENT_USE, /// Context is used by a client for TLSv1 or higher. Use requireMinimumProtocol() or disableProtocols() to disable undesired older versions.
69 TLS_SERVER_USE, /// Context is used by a client for TLSv1 or higher. Use requireMinimumProtocol() or disableProtocols() to disable undesired older versions.
70 CLIENT_USE, /// DEPRECATED. Context is used by a client.
71 SERVER_USE, /// DEPRECATED. Context is used by a server.
72 TLSV1_CLIENT_USE, /// DEPRECATED. Context is used by a client requiring TLSv1.
73 TLSV1_SERVER_USE, /// DEPRECATED. Context is used by a server requiring TLSv1.
74 TLSV1_1_CLIENT_USE, /// DEPRECATED. Context is used by a client requiring TLSv1.1 (OpenSSL 1.0.0 or newer).
75 TLSV1_1_SERVER_USE, /// DEPRECATED. Context is used by a server requiring TLSv1.1 (OpenSSL 1.0.0 or newer).
76 TLSV1_2_CLIENT_USE, /// DEPRECATED. Context is used by a client requiring TLSv1.2 (OpenSSL 1.0.1 or newer).
77 TLSV1_2_SERVER_USE, /// DEPRECATED. Context is used by a server requiring TLSv1.2 (OpenSSL 1.0.1 or newer).
78 TLSV1_3_CLIENT_USE, /// DEPRECATED. Context is used by a client requiring TLSv1.3 (OpenSSL 1.1.1 or newer).
79 TLSV1_3_SERVER_USE /// DEPRECATED. Context is used by a server requiring TLSv1.3 (OpenSSL 1.1.1 or newer).
80 };
81
83 {
85 /// Server: The server will not send a client certificate
86 /// request to the client, so the client will not send a certificate.
87 ///
88 /// Client: If not using an anonymous cipher (by default disabled),
89 /// the server will send a certificate which will be checked, but
90 /// the result of the check will be ignored.
91
93 /// Server: The server sends a client certificate request to the
94 /// client. The certificate returned (if any) is checked.
95 /// If the verification process fails, the TLS/SSL handshake is
96 /// immediately terminated with an alert message containing the
97 /// reason for the verification failure.
98 ///
99 /// Client: The server certificate is verified, if one is provided.
100 /// If the verification process fails, the TLS/SSL handshake is
101 /// immediately terminated with an alert message containing the
102 /// reason for the verification failure.
103
105 /// Server: If the client did not return a certificate, the TLS/SSL
106 /// handshake is immediately terminated with a handshake failure
107 /// alert.
108 ///
109 /// Client: Same as VERIFY_RELAXED.
110
112 /// Server: Only request a client certificate on the initial
113 /// TLS/SSL handshake. Do not ask for a client certificate
114 /// again in case of a renegotiation.
115 ///
116 /// Client: Same as VERIFY_RELAXED.
117 };
118
120 {
126 PROTO_TLSV1_3 = 0x20
127 };
128
130 {
132 /// Initializes the struct with default values.
133
135 /// Path to the private key file used for encryption.
136 /// Can be empty if no private key file is used.
137
139 /// Path to the certificate file (in PEM format).
140 ///
141 /// If the private key and the certificate are stored in the same file, this
142 /// can be empty if privateKeyFile is given.
143
145 /// Path to the file or directory containing the CA/root certificates.
146 /// Can be empty if the OpenSSL builtin CA certificates
147 /// are used (see loadDefaultCAs).
148
150 /// Specifies whether and how peer certificates are validated.
151 /// Defaults to VERIFY_RELAXED.
152
154 /// Sets the upper limit for verification chain sizes. Verification
155 /// will fail if a certificate chain larger than this is encountered.
156 /// Defaults to 9.
157
159 /// Specifies whether the builtin CA certificates from OpenSSL are used.
160 /// Defaults to false.
161
163 /// Specifies whether Client should verify OCSP Response
164 /// Defaults to false.
165
167 /// Specifies the supported ciphers in OpenSSL notation.
168 /// Defaults to "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH".
169
171 /// Specifies a file containing Diffie-Hellman parameters.
172 /// If empty, the default parameters are used.
173
175 /// If set to true, will use 2048-bit MODP Group with 256-bit
176 /// prime order subgroup (RFC5114) instead of 1024-bit for DH.
177
178 std::string ecdhCurve;
179 /// OpenSSL 1.0.1 and earlier:
180 /// Specifies the name of the curve to use for ECDH, based
181 /// on the curve names specified in RFC 4492.
182 /// Defaults to "prime256v1".
183 /// OpenSSL 1.0.2 to 1.1.0:
184 /// Specifies the colon-separated list of curves
185 /// to be used for ECDH, based on the curve names
186 /// defined by OpenSSL, such as
187 /// "X448:X25519:P-521:P-384:P-256"
188 /// Defaults to the subset supported by the OpenSSL version
189 /// among the above.
190 /// OpenSSL 1.1.1 and above:
191 /// Specifies the colon-separated list of groups
192 /// (some of which can be curves) to be used for ECDH
193 /// and other TLSv1.3 ephemeral key negotiation, based
194 /// on the group names defined by OpenSSL. Defaults to
195 /// "X448:X25519:ffdhe4096:ffdhe3072:ffdhe2048:ffdhe6144:ffdhe8192:P-521:P-384:P-256"
196 };
197
198 using InvalidCertificateHandlerPtr = Poco::SharedPtr<InvalidCertificateHandler>;
199
200 Context(Usage usage, const Params& params);
201 /// Creates a Context using the given parameters.
202 ///
203 /// * usage specifies whether the context is used by a client or server.
204 /// * params specifies the context parameters.
205
206 Context(
207 Usage usage,
208 const std::string& privateKeyFile,
209 const std::string& certificateFile,
210 const std::string& caLocation,
211 VerificationMode verificationMode = VERIFY_RELAXED,
212 int verificationDepth = 9,
213 bool loadDefaultCAs = false,
214 const std::string& cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
215 /// Creates a Context.
216 ///
217 /// * usage specifies whether the context is used by a client or server.
218 /// * privateKeyFile contains the path to the private key file used for encryption.
219 /// Can be empty if no private key file is used.
220 /// * certificateFile contains the path to the certificate file (in PEM format).
221 /// If the private key and the certificate are stored in the same file, this
222 /// can be empty if privateKeyFile is given.
223 /// * caLocation contains the path to the file or directory containing the
224 /// CA/root certificates. Can be empty if the OpenSSL builtin CA certificates
225 /// are used (see loadDefaultCAs).
226 /// * verificationMode specifies whether and how peer certificates are validated.
227 /// * verificationDepth sets the upper limit for verification chain sizes. Verification
228 /// will fail if a certificate chain larger than this is encountered.
229 /// * loadDefaultCAs specifies whether the builtin CA certificates from OpenSSL are used.
230 /// * cipherList specifies the supported ciphers in OpenSSL notation.
231 ///
232 /// Note: If the private key is protected by a passphrase, a PrivateKeyPassphraseHandler
233 /// must have been setup with the SSLManager, or the SSLManager's PrivateKeyPassphraseRequired
234 /// event must be handled.
235
236 Context(
237 Usage usage,
238 const std::string& caLocation,
239 VerificationMode verificationMode = VERIFY_RELAXED,
240 int verificationDepth = 9,
241 bool loadDefaultCAs = false,
242 const std::string& cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
243 /// Creates a Context.
244 ///
245 /// * usage specifies whether the context is used by a client or server.
246 /// * caLocation contains the path to the file or directory containing the
247 /// CA/root certificates. Can be empty if the OpenSSL builtin CA certificates
248 /// are used (see loadDefaultCAs).
249 /// * verificationMode specifies whether and how peer certificates are validated.
250 /// * verificationDepth sets the upper limit for verification chain sizes. Verification
251 /// will fail if a certificate chain larger than this is encountered.
252 /// * loadDefaultCAs specifies whether the builtin CA certificates from OpenSSL are used.
253 /// * cipherList specifies the supported ciphers in OpenSSL notation.
254 ///
255 /// Note that a private key and/or certificate must be specified with
256 /// usePrivateKey()/useCertificate() before the Context can be used.
257
259 /// Destroys the Context.
260
261 void useCertificate(const Poco::Crypto::X509Certificate& certificate);
262 /// Sets the certificate to be used by the Context.
263 ///
264 /// To set-up a complete certificate chain, it might be
265 /// necessary to call addChainCertificate() to specify
266 /// additional certificates.
267 ///
268 /// Note that useCertificate() must always be called before
269 /// usePrivateKey().
270
271 void addChainCertificate(const Poco::Crypto::X509Certificate& certificate);
272 /// Adds a certificate for certificate chain validation.
273
275 /// Add one trusted certification authority to be used by the Context.
276
277 void usePrivateKey(const Poco::Crypto::RSAKey& key);
278 /// Sets the private key to be used by the Context.
279 ///
280 /// Note that useCertificate() must always be called before
281 /// usePrivateKey().
282 ///
283 /// Note: If the private key is protected by a passphrase, a PrivateKeyPassphraseHandler
284 /// must have been setup with the SSLManager, or the SSLManager's PrivateKeyPassphraseRequired
285 /// event must be handled.
286
287 void usePrivateKey(const Poco::Crypto::EVPPKey &pkey);
288 /// Sets the private key to be used by the Context.
289 ///
290 /// Note that useCertificate() must always be called before
291 /// usePrivateKey().
292 ///
293 /// Note: If the private key is protected by a passphrase, a PrivateKeyPassphraseHandler
294 /// must have been setup with the SSLManager, or the SSLManager's PrivateKeyPassphraseRequired
295 /// event must be handled.
296
297 SSL_CTX* sslContext() const;
298 /// Returns the underlying OpenSSL SSL Context object.
299
300 Usage usage() const;
301 /// Returns whether the context is for use by a client or by a server
302 /// and whether TLSv1 is required.
303
304 bool isForServerUse() const;
305 /// Returns true iff the context is for use by a server.
306
308 /// Returns the verification mode.
309
310 void enableSessionCache(bool flag = true);
311 /// Enable or disable SSL/TLS session caching.
312 /// For session caching to work, it must be enabled
313 /// on the server, as well as on the client side.
314 ///
315 /// The default is disabled session caching.
316 ///
317 /// To enable session caching on the server side, use the
318 /// two-argument version of this method to specify
319 /// a session ID context.
320
321 void enableSessionCache(bool flag, const std::string& sessionIdContext);
322 /// Enables or disables SSL/TLS session caching on the server.
323 /// For session caching to work, it must be enabled
324 /// on the server, as well as on the client side.
325 ///
326 /// SessionIdContext contains the application's unique
327 /// session ID context, which becomes part of each
328 /// session identifier generated by the server within this
329 /// context. SessionIdContext can be an arbitrary sequence
330 /// of bytes with a maximum length of SSL_MAX_SSL_SESSION_ID_LENGTH.
331 ///
332 /// A non-empty sessionIdContext should be specified even if
333 /// session caching is disabled to avoid problems with clients
334 /// requesting to reuse a session (e.g. Firefox 3.6).
335 ///
336 /// This method may only be called on SERVER_USE Context objects.
337
339 /// Returns true iff the session cache is enabled.
340
341 void setSessionCacheSize(std::size_t size);
342 /// Sets the maximum size of the server session cache, in number of
343 /// sessions. The default size (according to OpenSSL documentation)
344 /// is 1024*20, which may be too large for many applications,
345 /// especially on embedded platforms with limited memory.
346 ///
347 /// Specifying a size of 0 will set an unlimited cache size.
348 ///
349 /// This method may only be called on SERVER_USE Context objects.
350
351 std::size_t getSessionCacheSize() const;
352 /// Returns the current maximum size of the server session cache.
353 ///
354 /// This method may only be called on SERVER_USE Context objects.
355
356 void setSessionTimeout(long seconds);
357 /// Sets the timeout (in seconds) of cached sessions on the server.
358 /// A cached session will be removed from the cache if it has
359 /// not been used for the given number of seconds.
360 ///
361 /// This method may only be called on SERVER_USE Context objects.
362
363 long getSessionTimeout() const;
364 /// Returns the timeout (in seconds) of cached sessions on the server.
365 ///
366 /// This method may only be called on SERVER_USE Context objects.
367
369 /// Flushes the SSL session cache on the server.
370 ///
371 /// This method may only be called on SERVER_USE Context objects.
372
374 /// Enable or disable the automatic post-connection
375 /// extended certificate verification.
376 ///
377 /// See X509Certificate::verify() for more information.
378
380 /// Returns true iff automatic extended certificate
381 /// verification is enabled.
382
384 /// Newer versions of OpenSSL support RFC 4507 tickets for stateless
385 /// session resumption.
386 ///
387 /// The feature can be disabled by calling this method.
388
389 void disableProtocols(int protocols);
390 /// Disables the given protocols.
391 ///
392 /// The protocols to be disabled are specified by OR-ing
393 /// values from the Protocols enumeration, e.g.:
394 ///
395 /// context.disableProtocols(PROTO_SSLV2 | PROTO_SSLV3);
396
398 /// Disables all protocol version lower than the given one.
399 /// To require at least TLS 1.2 or later:
400 ///
401 /// context.requireMinimumProtocol(PROTO_TLSV1_2);
402
404 /// When choosing a cipher, use the server's preferences instead of the client
405 /// preferences. When not called, the SSL server will always follow the clients
406 /// preferences. When called, the SSL/TLS server will choose following its own
407 /// preferences.
408
410 /// Returns true if automatic OCSP response
411 /// reception and verification is enabled for client connections
412
413 void setInvalidCertificateHandler(InvalidCertificateHandlerPtr pInvalidCertificageHandler);
414 /// Sets a Context-specific InvalidCertificateHandler.
415 ///
416 /// If specified, this InvalidCertificateHandler will be used instead of the
417 /// one globally set in the SSLManager.
418
419 InvalidCertificateHandlerPtr getInvalidCertificateHandler() const;
420 /// Returns the InvalidCertificateHandler set for this Context,
421 /// or a null pointer if none has been set.
422
423private:
424 void init(const Params& params);
425 /// Initializes the Context with the given parameters.
426
427 void initDH(bool use2048Bits, const std::string& dhFile);
428 /// Initializes the Context with Diffie-Hellman parameters.
429
430 void initECDH(const std::string& curve);
431 /// Initializes the Context with Elliptic-Curve Diffie-Hellman key
432 /// exchange curve parameters.
433
435 /// Create a SSL_CTX object according to Context configuration.
436
442 InvalidCertificateHandlerPtr _pInvalidCertificateHandler;
443};
444
445
446//
447// inlines
448//
449inline Context::Usage Context::usage() const
450{
451 return _usage;
452}
453
454
455inline bool Context::isForServerUse() const
456{
457 return _usage == SERVER_USE
463}
464
465
467{
468 return _mode;
469}
470
471
472inline SSL_CTX* Context::sslContext() const
473{
474 return _pSSLContext;
475}
476
477
479{
481}
482
483
485{
487}
488
489
490inline Context::InvalidCertificateHandlerPtr Context::getInvalidCertificateHandler() const
491{
493}
494
495
496} } // namespace Poco::Net
497
498
499#endif // NetSSL_Context_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 Net_API
Definition Net.h:47
#define NetSSL_API
Definition NetSSL.h:48
#define POCO_OS_WINDOWS_NT
Definition Platform.h:43
#define POCO_UNUSED
Definition Platform.h:274
#define POCO_OS_ANDROID
Definition Platform.h:41
#define POCO_OS_QNX
Definition Platform.h:37
#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
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)
This class represents a X509 Certificate.
std::string displayText() const
Returns the exception code if defined.
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)
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.
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)
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()
void NetSSL_API initializeSSL()
void Net_API uninitializeNetwork()
void Net_API initializeNetwork()
void NetSSL_API uninitializeSSL()
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
#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
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)