mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-07-07 09:27:10 +02:00
Update POCO library.
This commit is contained in:
@ -27,7 +27,7 @@ namespace Net {
|
||||
|
||||
|
||||
class NetSSL_Win_API AcceptCertificateHandler: public InvalidCertificateHandler
|
||||
/// A AcceptCertificateHandler is invoked whenever an error
|
||||
/// A AcceptCertificateHandler is invoked whenever an error
|
||||
/// occurs verifying the certificate. It always accepts
|
||||
/// the certificate.
|
||||
///
|
||||
|
@ -33,7 +33,7 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
template <int numBufs>
|
||||
template <int numBufs>
|
||||
class AutoSecBufferDesc: public SecBufferDesc
|
||||
/// AutoSecBufferDesc is a helper class for automatic initialization and release of SecBuffer objects.
|
||||
{
|
||||
@ -45,7 +45,7 @@ public:
|
||||
{
|
||||
poco_check_ptr (_pSec);
|
||||
poco_static_assert (numBufs > 0);
|
||||
|
||||
|
||||
initBuffers();
|
||||
cBuffers = numBufs;
|
||||
pBuffers = _buffers;
|
||||
|
@ -32,7 +32,7 @@ class NetSSL_Win_API CertificateHandlerFactory
|
||||
/// A CertificateHandlerFactory is responsible for creating InvalidCertificateHandlers.
|
||||
///
|
||||
/// You don't need to access this class directly. Use the macro
|
||||
/// POCO_REGISTER_CHFACTORY(namespace, InvalidCertificateHandlerName)
|
||||
/// POCO_REGISTER_CHFACTORY(namespace, InvalidCertificateHandlerName)
|
||||
/// instead (see the documentation of InvalidCertificateHandler for an example).
|
||||
{
|
||||
public:
|
||||
@ -50,7 +50,7 @@ public:
|
||||
class NetSSL_Win_API CertificateHandlerFactoryRegistrar
|
||||
/// Registrar class which automatically registers CertificateHandlerFactory at the CertificateHandlerFactoryMgr.
|
||||
/// You don't need to access this class directly. Use the macro
|
||||
/// POCO_REGISTER_CHFACTORY(namespace, InvalidCertificateHandlerName)
|
||||
/// POCO_REGISTER_CHFACTORY(namespace, InvalidCertificateHandlerName)
|
||||
/// instead (see the documentation of InvalidCertificateHandler for an example).
|
||||
{
|
||||
public:
|
||||
|
@ -33,7 +33,7 @@ class NetSSL_Win_API CertificateHandlerFactoryMgr
|
||||
{
|
||||
public:
|
||||
using FactoriesMap = std::map<std::string, Poco::SharedPtr<CertificateHandlerFactory>>;
|
||||
|
||||
|
||||
CertificateHandlerFactoryMgr();
|
||||
/// Creates the CertificateHandlerFactoryMgr.
|
||||
|
||||
@ -46,12 +46,12 @@ public:
|
||||
|
||||
bool hasFactory(const std::string& name) const;
|
||||
/// Returns true if for the given name a factory is already registered
|
||||
|
||||
|
||||
const CertificateHandlerFactory* getFactory(const std::string& name) const;
|
||||
/// Returns NULL if for the given name a factory does not exist, otherwise the factory is returned
|
||||
|
||||
void removeFactory(const std::string& name);
|
||||
/// Removes the factory from the manager.
|
||||
/// Removes the factory from the manager.
|
||||
|
||||
private:
|
||||
FactoriesMap _factories;
|
||||
|
@ -28,7 +28,7 @@ namespace Net {
|
||||
|
||||
class NetSSL_Win_API ConsoleCertificateHandler: public InvalidCertificateHandler
|
||||
/// A ConsoleCertificateHandler is invoked whenever an error occurs verifying the certificate.
|
||||
///
|
||||
///
|
||||
/// The certificate is printed to stdout and the user is asked via console if he wants to accept it.
|
||||
{
|
||||
public:
|
||||
|
@ -68,37 +68,37 @@ public:
|
||||
TLSV1_3_SERVER_USE /// DEPRECATED. Context is used by a server requiring TLSv1.3. Not supported on Windows Embedded Compact.
|
||||
};
|
||||
|
||||
enum VerificationMode
|
||||
enum VerificationMode
|
||||
{
|
||||
VERIFY_NONE = 0,
|
||||
/// Server: The server will not send a client certificate
|
||||
/// request to the client, so the client will not send a certificate.
|
||||
VERIFY_NONE = 0,
|
||||
/// Server: The server will not send a client certificate
|
||||
/// request to the client, so the client will not send a certificate.
|
||||
///
|
||||
/// Client: If not using an anonymous cipher (by default disabled),
|
||||
/// Client: If not using an anonymous cipher (by default disabled),
|
||||
/// the server will send a certificate which will be checked, but
|
||||
/// the result of the check will be ignored.
|
||||
|
||||
VERIFY_RELAXED = 1,
|
||||
/// Server: The server sends a client certificate request to the
|
||||
/// client. The certificate returned (if any) is checked.
|
||||
/// If the verification process fails, the TLS/SSL handshake is
|
||||
/// immediately terminated with an alert message containing the
|
||||
/// reason for the verification failure.
|
||||
///
|
||||
/// Client: The server certificate is verified, if one is provided.
|
||||
VERIFY_RELAXED = 1,
|
||||
/// Server: The server sends a client certificate request to the
|
||||
/// client. The certificate returned (if any) is checked.
|
||||
/// If the verification process fails, the TLS/SSL handshake is
|
||||
/// immediately terminated with an alert message containing the
|
||||
/// reason for the verification failure.
|
||||
/// immediately terminated with an alert message containing the
|
||||
/// reason for the verification failure.
|
||||
///
|
||||
/// Client: The server certificate is verified, if one is provided.
|
||||
/// If the verification process fails, the TLS/SSL handshake is
|
||||
/// immediately terminated with an alert message containing the
|
||||
/// reason for the verification failure.
|
||||
|
||||
VERIFY_STRICT = 2,
|
||||
/// Server: If the client did not return a certificate, the TLS/SSL
|
||||
/// Server: If the client did not return a certificate, the TLS/SSL
|
||||
/// handshake is immediately terminated with a handshake failure
|
||||
/// alert.
|
||||
/// alert.
|
||||
///
|
||||
/// Client: Same as VERIFY_RELAXED.
|
||||
/// Client: Same as VERIFY_RELAXED.
|
||||
|
||||
VERIFY_ONCE = 1
|
||||
/// Same as VERIFY_RELAXED (provided for interface compatibility with
|
||||
/// Same as VERIFY_RELAXED (provided for interface compatibility with
|
||||
/// the OpenSSL implementation.
|
||||
};
|
||||
|
||||
@ -122,26 +122,26 @@ public:
|
||||
/// If specified, the windows machine certificate store is used (server only).
|
||||
/// Otherwise, the user's certificate store is used.
|
||||
OPT_USE_STRONG_CRYPTO = 0x08,
|
||||
/// Disable known weak cryptographic algorithms, cipher suites, and
|
||||
/// SSL/TLS protocol versions that may be otherwise enabled for better interoperability.
|
||||
/// Disable known weak cryptographic algorithms, cipher suites, and
|
||||
/// SSL/TLS protocol versions that may be otherwise enabled for better interoperability.
|
||||
OPT_LOAD_CERT_FROM_FILE = 0x10,
|
||||
/// Load certificate and private key from a PKCS #12 (.pfx) file,
|
||||
/// Load certificate and private key from a PKCS #12 (.pfx) file,
|
||||
/// and not from the certificate store.
|
||||
OPT_DEFAULTS = OPT_PERFORM_REVOCATION_CHECK | OPT_TRUST_ROOTS_WIN_CERT_STORE | OPT_USE_STRONG_CRYPTO
|
||||
};
|
||||
|
||||
Context(Usage usage,
|
||||
const std::string& certificateNameOrPath,
|
||||
const std::string& certificateNameOrPath,
|
||||
VerificationMode verMode = VERIFY_RELAXED,
|
||||
int options = OPT_DEFAULTS,
|
||||
const std::string& certificateStoreName = CERT_STORE_MY);
|
||||
/// Creates a Context.
|
||||
///
|
||||
///
|
||||
/// * usage specifies whether the context is used by a client or server,
|
||||
/// as well as which protocol to use.
|
||||
/// * certificateNameOrPath specifies either the subject name of the certificate to use,
|
||||
/// or the path of a PKCS #12 file containing the certificate and corresponding private key.
|
||||
/// If a subject name is specified, the certificate must be located in the certificate
|
||||
/// If a subject name is specified, the certificate must be located in the certificate
|
||||
/// store specified by certificateStoreName. If a path is given, the OPT_LOAD_CERT_FROM_FILE
|
||||
/// option must be set.
|
||||
/// * verificationMode specifies whether and how peer certificates are validated.
|
||||
@ -153,7 +153,7 @@ public:
|
||||
/// Note: you can use OpenSSL to convert a certificate and private key in PEM format
|
||||
/// into PKCS #12 format required to import into the Context:
|
||||
///
|
||||
/// openssl pkcs12 -export -inkey cert.key -in cert.crt -out cert.pfx
|
||||
/// openssl pkcs12 -export -inkey cert.key -in cert.crt -out cert.pfx
|
||||
|
||||
~Context();
|
||||
/// Destroys the Context.
|
||||
@ -176,9 +176,9 @@ public:
|
||||
/// extended certificate verification.
|
||||
///
|
||||
/// See X509Certificate::verify() for more information.
|
||||
|
||||
|
||||
bool extendedCertificateVerificationEnabled() const;
|
||||
/// Returns true iff automatic extended certificate
|
||||
/// Returns true iff automatic extended certificate
|
||||
/// verification is enabled.
|
||||
|
||||
int options() const;
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
{
|
||||
HTTPS_PORT = 443
|
||||
};
|
||||
|
||||
|
||||
HTTPSClientSession();
|
||||
/// Creates an unconnected HTTPSClientSession.
|
||||
|
||||
@ -122,25 +122,25 @@ public:
|
||||
~HTTPSClientSession();
|
||||
/// Destroys the HTTPSClientSession and closes
|
||||
/// the underlying socket.
|
||||
|
||||
|
||||
bool secure() const;
|
||||
/// Return true iff the session uses SSL or TLS,
|
||||
/// or false otherwise.
|
||||
|
||||
|
||||
X509Certificate serverCertificate();
|
||||
/// Returns the server's certificate.
|
||||
///
|
||||
/// The certificate is available after the first request has been sent.
|
||||
|
||||
|
||||
Session::Ptr sslSession();
|
||||
/// Returns the SSL Session object for the current
|
||||
/// Returns the SSL Session object for the current
|
||||
/// connection, if session caching has been enabled for
|
||||
/// the HTTPSClientSession's Context. A null pointer is
|
||||
/// the HTTPSClientSession's Context. A null pointer is
|
||||
/// returned otherwise.
|
||||
///
|
||||
/// The Session object can be obtained after the first request has
|
||||
/// been sent.
|
||||
|
||||
|
||||
// HTTPSession
|
||||
void abort();
|
||||
|
||||
@ -153,7 +153,7 @@ protected:
|
||||
private:
|
||||
HTTPSClientSession(const HTTPSClientSession&);
|
||||
HTTPSClientSession& operator = (const HTTPSClientSession&);
|
||||
|
||||
|
||||
Context::Ptr _pContext;
|
||||
Session::Ptr _pSession;
|
||||
};
|
||||
|
@ -49,27 +49,27 @@ public:
|
||||
|
||||
~HTTPSStreamFactory();
|
||||
/// Destroys the HTTPSStreamFactory.
|
||||
|
||||
|
||||
std::istream* open(const Poco::URI& uri);
|
||||
/// Creates and opens a HTTPS stream for the given URI.
|
||||
/// The URI must be a https://... URI.
|
||||
///
|
||||
/// Throws a NetException if anything goes wrong.
|
||||
|
||||
|
||||
static void registerFactory();
|
||||
/// Registers the HTTPSStreamFactory with the
|
||||
/// default URIStreamOpener instance.
|
||||
/// default URIStreamOpener instance.
|
||||
|
||||
static void unregisterFactory();
|
||||
/// Unregisters the HTTPSStreamFactory with the
|
||||
/// default URIStreamOpener instance.
|
||||
|
||||
/// default URIStreamOpener instance.
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
MAX_REDIRECTS = 10
|
||||
};
|
||||
|
||||
|
||||
std::string _proxyHost;
|
||||
Poco::UInt16 _proxyPort;
|
||||
std::string _proxyUsername;
|
||||
|
@ -30,9 +30,9 @@ class NetSSL_Win_API InvalidCertificateHandler
|
||||
/// A InvalidCertificateHandler is invoked whenever an error occurs verifying the certificate. It allows the user
|
||||
/// to inspect and accept/reject the certificate.
|
||||
/// One can install one's own InvalidCertificateHandler by implementing this interface. Note that
|
||||
/// in the implementation file of the subclass the following code must be present (assuming you use the namespace My_API
|
||||
/// in the implementation file of the subclass the following code must be present (assuming you use the namespace My_API
|
||||
/// and the name of your handler class is MyGuiHandler):
|
||||
///
|
||||
///
|
||||
/// #include "Poco/Net/CertificateHandlerFactory.h"
|
||||
/// ...
|
||||
/// POCO_REGISTER_CHFACTORY(My_API, MyGuiHandler)
|
||||
@ -43,7 +43,7 @@ class NetSSL_Win_API InvalidCertificateHandler
|
||||
///
|
||||
/// or in case one uses Poco::Util::Application one can rely on an XML configuration and put the following entry
|
||||
/// under the path openSSL.invalidCertificateHandler:
|
||||
///
|
||||
///
|
||||
/// <invalidCertificateHandler>
|
||||
/// <name>MyGuiHandler<name>
|
||||
/// <options>
|
||||
@ -56,7 +56,7 @@ class NetSSL_Win_API InvalidCertificateHandler
|
||||
public:
|
||||
InvalidCertificateHandler(bool handleErrorsOnServerSide);
|
||||
/// Creates the InvalidCertificateHandler.
|
||||
///
|
||||
///
|
||||
/// Set handleErrorsOnServerSide to true if the certificate handler is used on the server side.
|
||||
/// Automatically registers at one of the SSLManager::VerificationError events.
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace Net {
|
||||
|
||||
|
||||
class NetSSL_Win_API KeyFileHandler: public PrivateKeyPassphraseHandler
|
||||
/// An implementation of PrivateKeyPassphraseHandler that
|
||||
/// An implementation of PrivateKeyPassphraseHandler that
|
||||
/// reads the key for a certificate from a configuration file
|
||||
/// under the path "openSSL.privateKeyPassphraseHandler.options.password".
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ void NetSSL_Win_API initializeSSL();
|
||||
/// Can be called multiple times; however, for every call to
|
||||
/// initializeSSL(), a matching call to uninitializeSSL()
|
||||
/// must be performed.
|
||||
|
||||
|
||||
|
||||
void NetSSL_Win_API uninitializeSSL();
|
||||
/// Uninitializes the NetSSL library and
|
||||
|
@ -32,7 +32,7 @@ class NetSSL_Win_API PrivateKeyFactory
|
||||
/// A PrivateKeyFactory is responsible for creating PrivateKeyPassphraseHandlers.
|
||||
///
|
||||
/// You don't need to access this class directly. Use the macro
|
||||
/// POCO_REGISTER_KEYFACTORY(namespace, PrivateKeyPassphraseHandlerName)
|
||||
/// POCO_REGISTER_KEYFACTORY(namespace, PrivateKeyPassphraseHandlerName)
|
||||
/// instead (see the documentation of PrivateKeyPassphraseHandler for an example).
|
||||
{
|
||||
public:
|
||||
@ -51,7 +51,7 @@ class NetSSL_Win_API PrivateKeyFactoryRegistrar
|
||||
/// Registrar class which automatically registers PrivateKeyFactories at the PrivateKeyFactoryMgr.
|
||||
///
|
||||
/// You don't need to access this class directly. Use the macro
|
||||
/// POCO_REGISTER_KEYFACTORY(namespace, PrivateKeyPassphraseHandlerName)
|
||||
/// POCO_REGISTER_KEYFACTORY(namespace, PrivateKeyPassphraseHandlerName)
|
||||
/// instead (see the documentation of PrivateKeyPassphraseHandler for an example).
|
||||
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ class NetSSL_Win_API PrivateKeyFactoryMgr
|
||||
{
|
||||
public:
|
||||
using FactoriesMap = std::map<std::string, Poco::SharedPtr<PrivateKeyFactory>>;
|
||||
|
||||
|
||||
PrivateKeyFactoryMgr();
|
||||
/// Creates the PrivateKeyFactoryMgr.
|
||||
|
||||
@ -46,12 +46,12 @@ public:
|
||||
|
||||
bool hasFactory(const std::string& name) const;
|
||||
/// Returns true if for the given name a factory is already registered
|
||||
|
||||
|
||||
const PrivateKeyFactory* getFactory(const std::string& name) const;
|
||||
/// Returns NULL if for the given name a factory does not exist, otherwise the factory is returned
|
||||
|
||||
void removeFactory(const std::string& name);
|
||||
/// Removes the factory from the manager.
|
||||
/// Removes the factory from the manager.
|
||||
|
||||
private:
|
||||
FactoriesMap _factories;
|
||||
|
@ -29,9 +29,9 @@ class NetSSL_Win_API PrivateKeyPassphraseHandler
|
||||
/// A passphrase handler is needed whenever the private key of a certificate is loaded and the certificate is protected
|
||||
/// by a passphrase. The PrivateKeyPassphraseHandler's task is to provide that passphrase.
|
||||
/// One can install one's own PrivateKeyPassphraseHandler by implementing this interface. Note that
|
||||
/// in the implementation file of the subclass the following code must be present (assuming you use the namespace My_API
|
||||
/// in the implementation file of the subclass the following code must be present (assuming you use the namespace My_API
|
||||
/// and the name of your handler class is MyGuiHandler):
|
||||
///
|
||||
///
|
||||
/// #include "Poco/Net/PrivateKeyFactory.h"
|
||||
/// ...
|
||||
/// POCO_REGISTER_KEYFACTORY(My_API, MyGuiHandler)
|
||||
@ -42,7 +42,7 @@ class NetSSL_Win_API PrivateKeyPassphraseHandler
|
||||
///
|
||||
/// or in case one's application extends Poco::Util::Application one can use an XML configuration and put the following entry
|
||||
/// under the path openSSL.privateKeyPassphraseHandler:
|
||||
///
|
||||
///
|
||||
/// <privateKeyPassphraseHandler>
|
||||
/// <name>MyGuiHandler</name>
|
||||
/// <options>
|
||||
|
@ -27,7 +27,7 @@ namespace Net {
|
||||
|
||||
|
||||
class NetSSL_Win_API RejectCertificateHandler: public InvalidCertificateHandler
|
||||
/// A RejectCertificateHandler is invoked whenever an error
|
||||
/// A RejectCertificateHandler is invoked whenever an error
|
||||
/// occurs verifying the certificate. It always rejects
|
||||
/// the certificate.
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ class Context;
|
||||
|
||||
|
||||
class NetSSL_Win_API SSLManager
|
||||
/// SSLManager is a singleton for holding the default server/client
|
||||
/// SSLManager is a singleton for holding the default server/client
|
||||
/// Context and handling callbacks for certificate verification errors
|
||||
/// and private key passphrases.
|
||||
///
|
||||
@ -66,7 +66,7 @@ class NetSSL_Win_API SSLManager
|
||||
/// ClientVerificationError and PrivateKeyPassphraseRequired events
|
||||
/// must be registered.
|
||||
///
|
||||
/// An exemplary documentation which sets either the server or client default context and creates
|
||||
/// An exemplary documentation which sets either the server or client default context and creates
|
||||
/// a PrivateKeyPassphraseHandler that reads the password from the XML file looks like this:
|
||||
///
|
||||
/// <AppConfig>
|
||||
@ -100,28 +100,28 @@ class NetSSL_Win_API SSLManager
|
||||
/// Following is a list of supported configuration properties. Property names must always
|
||||
/// be prefixed with openSSL.server or openSSL.client. Some properties are only supported
|
||||
/// for servers.
|
||||
///
|
||||
///
|
||||
/// - certificateName (string): The subject name of the certificate to use. The certificate must
|
||||
/// be available in the Windows user or machine certificate store.
|
||||
/// be available in the Windows user or machine certificate store.
|
||||
/// - certificatePath (string): The path of a certificate and private key file in PKCS #12 format.
|
||||
/// - certificateStore (string): The certificate store location to use.
|
||||
/// - certificateStore (string): The certificate store location to use.
|
||||
/// Valid values are "MY", "Root", "Trust" or "CA". Defaults to "MY".
|
||||
/// - verificationMode (string): Specifies whether and how peer certificates are validated (see
|
||||
/// the Context class for details). Valid values are "none", "relaxed", "strict". Defaults to "relaxed".
|
||||
/// - revocationCheck (boolean): Enable or disable checking of certificates against revocation list.
|
||||
/// - revocationCheck (boolean): Enable or disable checking of certificates against revocation list.
|
||||
/// Defaults to true. Not supported (ignored) on Windows Embedded Compact.
|
||||
/// - trustRoots (boolean): Trust root certificates from Windows root certificate store. Defaults to true.
|
||||
/// - useMachineStore (boolean): Use Windows machine certificate store instead of user store (server only).
|
||||
/// Special user privileges may be required. Defaults to false.
|
||||
/// - useStrongCrypto (boolean): Disable known weak cryptographic algorithms, cipher suites, and
|
||||
/// SSL/TLS protocol versions that may be otherwise enabled for better interoperability.
|
||||
/// - useStrongCrypto (boolean): Disable known weak cryptographic algorithms, cipher suites, and
|
||||
/// SSL/TLS protocol versions that may be otherwise enabled for better interoperability.
|
||||
/// Defaults to true.
|
||||
/// - privateKeyPassphraseHandler.name (string): The name of the class (subclass of PrivateKeyPassphraseHandler)
|
||||
/// used for obtaining the passphrase for accessing the private key.
|
||||
/// - privateKeyPassphraseHandler.options.password (string): The password to be used by KeyFileHandler.
|
||||
/// - invalidCertificateHandler.name: The name of the class (subclass of CertificateHandler)
|
||||
/// used for confirming invalid certificates.
|
||||
/// - requireTLSv1 (boolean): Require a TLSv1 connection.
|
||||
/// - requireTLSv1 (boolean): Require a TLSv1 connection.
|
||||
/// - requireTLSv1_1 (boolean): Require a TLSv1.1 connection. Not supported on Windows Embedded Compact.
|
||||
/// - requireTLSv1_2 (boolean): Require a TLSv1.2 connection. Not supported on Windows Embedded Compact.
|
||||
{
|
||||
@ -149,7 +149,7 @@ public:
|
||||
/// pCertificateHandler can be 0. However, in this case, event delegates
|
||||
/// must be registered with the ServerVerificationError event.
|
||||
///
|
||||
/// Note: Always create the handlers (or register the corresponding event delegates) before creating
|
||||
/// Note: Always create the handlers (or register the corresponding event delegates) before creating
|
||||
/// the Context.
|
||||
///
|
||||
/// Valid initialization code would be:
|
||||
@ -164,7 +164,7 @@ public:
|
||||
/// pCertificateHandler can be 0. However, in this case, event delegates
|
||||
/// must be registered with the ClientVerificationError event.
|
||||
///
|
||||
/// Note: Always create the handlers (or register the corresponding event delegates) before creating
|
||||
/// Note: Always create the handlers (or register the corresponding event delegates) before creating
|
||||
/// the Context, as during creation of the Context the passphrase for the private key might be needed.
|
||||
///
|
||||
/// Valid initialization code would be:
|
||||
@ -173,13 +173,13 @@ public:
|
||||
/// SSLManager::instance().initializeClient(pInvalidCertHandler, pContext);
|
||||
|
||||
Context::Ptr defaultServerContext();
|
||||
/// Returns the default Context used by the server.
|
||||
/// Returns the default Context used by the server.
|
||||
///
|
||||
/// Unless initializeServer() has been called, the first call to this method initializes the default Context
|
||||
/// from the application configuration.
|
||||
|
||||
Context::Ptr defaultClientContext();
|
||||
/// Returns the default Context used by the client.
|
||||
/// Returns the default Context used by the client.
|
||||
///
|
||||
/// Unless initializeClient() has been called, the first call to this method initializes the default Context
|
||||
/// from the application configuration.
|
||||
@ -201,11 +201,11 @@ public:
|
||||
/// If none is set, it will try to auto-initialize one from an application configuration.
|
||||
|
||||
PrivateKeyFactoryMgr& privateKeyFactoryMgr();
|
||||
/// Returns the private key factory manager which stores the
|
||||
/// Returns the private key factory manager which stores the
|
||||
/// factories for the different registered passphrase handlers for private keys.
|
||||
|
||||
CertificateHandlerFactoryMgr& certificateHandlerFactoryMgr();
|
||||
/// Returns the CertificateHandlerFactoryMgr which stores the
|
||||
/// Returns the CertificateHandlerFactoryMgr which stores the
|
||||
/// factories for the different registered certificate handlers.
|
||||
|
||||
void shutdown();
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
///
|
||||
/// Releases the socket's SocketImpl and
|
||||
/// attaches the SocketImpl from the other socket and
|
||||
/// increments the reference count of the SocketImpl.
|
||||
/// increments the reference count of the SocketImpl.
|
||||
|
||||
StreamSocket acceptConnection(SocketAddress& clientAddr);
|
||||
/// Get the next completed connection from the
|
||||
|
@ -34,7 +34,7 @@ class NetSSL_Win_API SecureStreamSocket: public StreamSocket
|
||||
///
|
||||
/// A few notes about nonblocking IO:
|
||||
/// sendBytes() and receiveBytes() can return a
|
||||
/// negative value when using a nonblocking socket, which means
|
||||
/// negative value when using a nonblocking socket, which means
|
||||
/// a SSL handshake is currently in progress and more data
|
||||
/// needs to be read or written for the handshake to continue.
|
||||
/// If sendBytes() or receiveBytes() return ERR_SSL_WANT_WRITE,
|
||||
@ -43,7 +43,7 @@ class NetSSL_Win_API SecureStreamSocket: public StreamSocket
|
||||
/// ERR_SSL_WANT_READ is returned, receiveBytes() must be called
|
||||
/// as soon as data is available for reading (indicated by select()).
|
||||
///
|
||||
/// The SSL handshake is delayed until the first sendBytes() or
|
||||
/// The SSL handshake is delayed until the first sendBytes() or
|
||||
/// receiveBytes() operation is performed on the socket. No automatic
|
||||
/// post connection check (checking the peer certificate for a valid
|
||||
/// hostname) is performed when using nonblocking I/O. To manually
|
||||
@ -56,7 +56,7 @@ public:
|
||||
ERR_SSL_WANT_READ = -1,
|
||||
ERR_SSL_WANT_WRITE = -2
|
||||
};
|
||||
|
||||
|
||||
SecureStreamSocket();
|
||||
/// Creates an unconnected secure stream socket
|
||||
/// using the default client SSL context.
|
||||
@ -83,17 +83,17 @@ public:
|
||||
/// agrees to reuse the session).
|
||||
|
||||
explicit SecureStreamSocket(const SocketAddress& address);
|
||||
/// Creates a secure stream socket using the default
|
||||
/// Creates a secure stream socket using the default
|
||||
/// client SSL context and connects it to
|
||||
/// the socket specified by address.
|
||||
|
||||
SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext);
|
||||
/// Creates a secure stream socket using the given
|
||||
/// Creates a secure stream socket using the given
|
||||
/// client SSL context and connects it to
|
||||
/// the socket specified by address.
|
||||
|
||||
SecureStreamSocket(const SocketAddress& address, Context::Ptr pContext, Session::Ptr pSession);
|
||||
/// Creates a secure stream socket using the given
|
||||
/// Creates a secure stream socket using the given
|
||||
/// client SSL context and connects it to
|
||||
/// the socket specified by address.
|
||||
///
|
||||
@ -102,21 +102,21 @@ public:
|
||||
/// agrees to reuse the session).
|
||||
|
||||
SecureStreamSocket(const SocketAddress& address, const std::string& hostName);
|
||||
/// Creates a secure stream socket using the default
|
||||
/// Creates a secure stream socket using the default
|
||||
/// client SSL context and connects it to
|
||||
/// the socket specified by address.
|
||||
///
|
||||
/// The given host name is used for certificate verification.
|
||||
|
||||
SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext);
|
||||
/// Creates a secure stream socket using the given
|
||||
/// Creates a secure stream socket using the given
|
||||
/// client SSL context and connects it to
|
||||
/// the socket specified by address.
|
||||
///
|
||||
/// The given host name is used for certificate verification.
|
||||
|
||||
SecureStreamSocket(const SocketAddress& address, const std::string& hostName, Context::Ptr pContext, Session::Ptr pSession);
|
||||
/// Creates a secure stream socket using the given
|
||||
/// Creates a secure stream socket using the given
|
||||
/// client SSL context and connects it to
|
||||
/// the socket specified by address.
|
||||
///
|
||||
@ -140,8 +140,8 @@ public:
|
||||
///
|
||||
/// Releases the socket's SocketImpl and
|
||||
/// attaches the SocketImpl from the other socket and
|
||||
/// increments the reference count of the SocketImpl.
|
||||
|
||||
/// increments the reference count of the SocketImpl.
|
||||
|
||||
bool havePeerCertificate() const;
|
||||
/// Returns true iff the peer has presented a
|
||||
/// certificate.
|
||||
@ -151,10 +151,10 @@ public:
|
||||
///
|
||||
/// Throws a SSLException if the peer did not
|
||||
/// present a certificate.
|
||||
|
||||
|
||||
void setPeerHostName(const std::string& hostName);
|
||||
/// Sets the peer's host name used for certificate validation.
|
||||
|
||||
|
||||
const std::string& getPeerHostName() const;
|
||||
/// Returns the peer's host name used for certificate validation.
|
||||
|
||||
@ -198,15 +198,15 @@ public:
|
||||
|
||||
Context::Ptr context() const;
|
||||
/// Returns the SSL context used by this socket.
|
||||
|
||||
|
||||
void setLazyHandshake(bool flag = true);
|
||||
/// Enable lazy SSL handshake. If enabled, the SSL handshake
|
||||
/// will be performed the first time date is sent or
|
||||
/// received over the connection.
|
||||
|
||||
|
||||
bool getLazyHandshake() const;
|
||||
/// Returns true if setLazyHandshake(true) has been called.
|
||||
|
||||
|
||||
void verifyPeerCertificate();
|
||||
/// Performs post-connect (or post-accept) peer certificate validation,
|
||||
/// using the peer host name set with setPeerHostName(), or the peer's
|
||||
@ -221,7 +221,7 @@ public:
|
||||
///
|
||||
/// Should only be used for non-blocking connections, after the
|
||||
/// initial SSL handshake has been performed (see completeHandshake()).
|
||||
|
||||
|
||||
int completeHandshake();
|
||||
/// Completes the SSL handshake.
|
||||
///
|
||||
@ -240,7 +240,7 @@ public:
|
||||
/// is enabled).
|
||||
///
|
||||
/// If no connection is established, returns null.
|
||||
|
||||
|
||||
void useSession(Session::Ptr pSession);
|
||||
/// Sets the SSL session to use for the next
|
||||
/// connection. Setting a previously saved Session
|
||||
@ -250,15 +250,15 @@ public:
|
||||
/// can be given.
|
||||
///
|
||||
/// Must be called before connect() to be effective.
|
||||
|
||||
|
||||
bool sessionWasReused();
|
||||
/// Returns true iff a reused session was negotiated during
|
||||
/// the handshake.
|
||||
|
||||
|
||||
void abort();
|
||||
/// Aborts the SSL connection by closing the underlying
|
||||
/// TCP connection. No orderly SSL shutdown is performed.
|
||||
|
||||
|
||||
protected:
|
||||
SecureStreamSocket(SocketImpl* pImpl);
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
/// Throws a Poco::InvalidAccessException.
|
||||
|
||||
void connect(const SocketAddress& address);
|
||||
/// Initializes the socket and establishes a connection to
|
||||
/// Initializes the socket and establishes a connection to
|
||||
/// the TCP server at the given address.
|
||||
///
|
||||
/// Can also be used for UDP sockets. In this case, no
|
||||
@ -54,19 +54,19 @@ public:
|
||||
/// packets are restricted to the specified address.
|
||||
|
||||
void connect(const SocketAddress& address, const Poco::Timespan& timeout);
|
||||
/// Initializes the socket, sets the socket timeout and
|
||||
/// Initializes the socket, sets the socket timeout and
|
||||
/// establishes a connection to the TCP server at the given address.
|
||||
|
||||
void connectNB(const SocketAddress& address);
|
||||
/// Initializes the socket and establishes a connection to
|
||||
/// Initializes the socket and establishes a connection to
|
||||
/// the TCP server at the given address. Prior to opening the
|
||||
/// connection the socket is set to nonblocking mode.
|
||||
|
||||
|
||||
void bind(const SocketAddress& address, bool reuseAddress = false);
|
||||
/// Not supported by a SecureStreamSocket.
|
||||
///
|
||||
/// Throws a Poco::InvalidAccessException.
|
||||
|
||||
|
||||
void listen(int backlog = 64);
|
||||
/// Not supported by a SecureStreamSocket.
|
||||
///
|
||||
@ -74,30 +74,30 @@ public:
|
||||
|
||||
void close();
|
||||
/// Close the socket.
|
||||
|
||||
|
||||
int sendBytes(const void* buffer, int length, int flags = 0);
|
||||
/// Sends the contents of the given buffer through
|
||||
/// the socket. Any specified flags are ignored.
|
||||
///
|
||||
/// Returns the number of bytes sent, which may be
|
||||
/// less than the number of bytes specified.
|
||||
|
||||
|
||||
int receiveBytes(void* buffer, int length, int flags = 0);
|
||||
/// Receives data from the socket and stores it
|
||||
/// in buffer. Up to length bytes are received.
|
||||
///
|
||||
/// Returns the number of bytes received.
|
||||
|
||||
|
||||
int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0);
|
||||
/// Not supported by a SecureStreamSocket.
|
||||
///
|
||||
/// Throws a Poco::InvalidAccessException.
|
||||
|
||||
|
||||
int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0);
|
||||
/// Not supported by a SecureStreamSocket.
|
||||
///
|
||||
/// Throws a Poco::InvalidAccessException.
|
||||
|
||||
|
||||
void sendUrgent(unsigned char data);
|
||||
/// Not supported by a SecureStreamSocket.
|
||||
///
|
||||
@ -116,27 +116,27 @@ public:
|
||||
///
|
||||
/// Since SSL does not support a half shutdown, this does
|
||||
/// nothing.
|
||||
|
||||
|
||||
void shutdownSend();
|
||||
/// Shuts down the receiving part of the socket connection.
|
||||
///
|
||||
/// Since SSL does not support a half shutdown, this does
|
||||
/// nothing.
|
||||
|
||||
|
||||
void shutdown();
|
||||
/// Shuts down the SSL connection.
|
||||
|
||||
|
||||
void abort();
|
||||
/// Aborts the connection by closing the underlying
|
||||
/// TCP connection. No orderly SSL shutdown is performed.
|
||||
|
||||
|
||||
bool secure() const;
|
||||
/// Returns true iff the socket's connection is secure
|
||||
/// (using SSL or TLS).
|
||||
|
||||
void setPeerHostName(const std::string& hostName);
|
||||
/// Sets the peer host name for certificate validation purposes.
|
||||
|
||||
|
||||
const std::string& getPeerHostName() const;
|
||||
/// Returns the peer host name.
|
||||
|
||||
@ -149,7 +149,7 @@ public:
|
||||
///
|
||||
/// Throws a SSLException if the peer did not
|
||||
/// present a certificate.
|
||||
|
||||
|
||||
Context::Ptr context() const;
|
||||
/// Returns the SSL context used by this socket.
|
||||
|
||||
@ -157,7 +157,7 @@ public:
|
||||
/// Enable lazy SSL handshake. If enabled, the SSL handshake
|
||||
/// will be performed the first time date is sent or
|
||||
/// received over the connection.
|
||||
|
||||
|
||||
bool getLazyHandshake() const;
|
||||
/// Returns true if setLazyHandshake(true) has been called.
|
||||
|
||||
@ -174,7 +174,7 @@ public:
|
||||
///
|
||||
/// If the SSL connection was the result of an accept(),
|
||||
/// the server-side handshake is completed, otherwise
|
||||
/// a client-side handshake is performed.
|
||||
/// a client-side handshake is performed.
|
||||
|
||||
Session::Ptr currentSession();
|
||||
/// Returns the SSL session of the current connection,
|
||||
@ -182,7 +182,7 @@ public:
|
||||
/// is enabled).
|
||||
///
|
||||
/// If no connection is established, returns null.
|
||||
|
||||
|
||||
void useSession(Session::Ptr pSession);
|
||||
/// Sets the SSL session to use for the next
|
||||
/// connection. Setting a previously saved Session
|
||||
@ -192,18 +192,18 @@ public:
|
||||
/// can be given.
|
||||
///
|
||||
/// Must be called before connect() to be effective.
|
||||
|
||||
|
||||
bool sessionWasReused();
|
||||
/// Returns true iff a reused session was negotiated during
|
||||
/// the handshake.
|
||||
|
||||
|
||||
protected:
|
||||
void acceptSSL();
|
||||
/// Performs a SSL server-side handshake.
|
||||
|
||||
|
||||
void connectSSL();
|
||||
/// Performs a SSL client-side handshake on an already connected TCP socket.
|
||||
|
||||
|
||||
~SecureStreamSocketImpl();
|
||||
/// Destroys the SecureStreamSocketImpl.
|
||||
|
||||
@ -251,13 +251,13 @@ inline Session::Ptr SecureStreamSocketImpl::currentSession()
|
||||
return Session::Ptr();//_impl.currentSession();
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void SecureStreamSocketImpl::useSession(Session::Ptr pSession)
|
||||
{
|
||||
//_impl.useSession(pSession);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline bool SecureStreamSocketImpl::sessionWasReused()
|
||||
{
|
||||
return false;//_impl.sessionWasReused();
|
||||
|
@ -38,11 +38,11 @@ class NetSSL_Win_API Session: public Poco::RefCountedObject
|
||||
public:
|
||||
using Ptr = Poco::AutoPtr<Session>;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
Session();
|
||||
/// Creates a new Session object, using the given
|
||||
/// SSL_SESSION object.
|
||||
///
|
||||
/// SSL_SESSION object.
|
||||
///
|
||||
/// The SSL_SESSION's reference count is not changed.
|
||||
|
||||
~Session();
|
||||
|
@ -44,9 +44,9 @@ public:
|
||||
NID_LOCALITY_NAME,
|
||||
NID_STATE_OR_PROVINCE,
|
||||
NID_ORGANIZATION_NAME,
|
||||
NID_ORGANIZATION_UNIT_NAME
|
||||
NID_ORGANIZATION_UNIT_NAME
|
||||
};
|
||||
|
||||
|
||||
explicit X509Certificate(const std::string& certPath);
|
||||
/// Creates the X509Certificate object by reading
|
||||
/// a certificate in PEM or DER format from a file.
|
||||
@ -64,13 +64,13 @@ public:
|
||||
|
||||
explicit X509Certificate(PCCERT_CONTEXT pCert);
|
||||
/// Creates the X509Certificate from an existing
|
||||
/// WinCrypt certificate. Ownership is taken of
|
||||
/// WinCrypt certificate. Ownership is taken of
|
||||
/// the certificate.
|
||||
|
||||
X509Certificate(PCCERT_CONTEXT pCert, bool shared);
|
||||
/// Creates the X509Certificate from an existing
|
||||
/// WinCrypt certificate. Ownership is taken of
|
||||
/// the certificate. If shared is true, the
|
||||
/// WinCrypt certificate. Ownership is taken of
|
||||
/// the certificate. If shared is true, the
|
||||
/// certificate's reference count is incremented.
|
||||
|
||||
X509Certificate(const X509Certificate& cert);
|
||||
@ -85,20 +85,20 @@ public:
|
||||
X509Certificate& operator = (X509Certificate&& cert) noexcept;
|
||||
/// Move-assigns a certificate.
|
||||
|
||||
void swap(X509Certificate& cert);
|
||||
void swap(X509Certificate& cert) noexcept;
|
||||
/// Exchanges the certificate with another one.
|
||||
|
||||
~X509Certificate();
|
||||
/// Destroys the X509Certificate.
|
||||
|
||||
const std::string& issuerName() const;
|
||||
/// Returns the certificate issuer's distinguished name.
|
||||
|
||||
/// Returns the certificate issuer's distinguished name.
|
||||
|
||||
std::string issuerName(NID nid) const;
|
||||
/// Extracts the information specified by the given
|
||||
/// NID (name identifier) from the certificate issuer's
|
||||
/// distinguished name.
|
||||
|
||||
|
||||
const std::string& subjectName() const;
|
||||
/// Returns the certificate subject's distinguished name.
|
||||
|
||||
@ -106,21 +106,21 @@ public:
|
||||
/// Extracts the information specified by the given
|
||||
/// NID (name identifier) from the certificate subject's
|
||||
/// distinguished name.
|
||||
|
||||
|
||||
std::string commonName() const;
|
||||
/// Returns the common name stored in the certificate
|
||||
/// subject's distinguished name.
|
||||
|
||||
|
||||
void extractNames(std::string& commonName, std::set<std::string>& domainNames) const;
|
||||
/// Extracts the common name and the alias domain names from the
|
||||
/// certificate.
|
||||
|
||||
|
||||
Poco::DateTime validFrom() const;
|
||||
/// Returns the date and time the certificate is valid from.
|
||||
|
||||
|
||||
Poco::DateTime expiresOn() const;
|
||||
/// Returns the date and time the certificate expires.
|
||||
|
||||
|
||||
bool issuedBy(const X509Certificate& issuerCertificate) const;
|
||||
/// Checks whether the certificate has been issued by
|
||||
/// the issuer given by issuerCertificate. This can be
|
||||
@ -138,9 +138,9 @@ public:
|
||||
/// For this check to be successful, the certificate must contain
|
||||
/// a domain name that matches the domain name
|
||||
/// of the host.
|
||||
///
|
||||
///
|
||||
/// Returns true if verification succeeded, or false otherwise.
|
||||
|
||||
|
||||
static bool verify(const Poco::Net::X509Certificate& cert, const std::string& hostName);
|
||||
/// Verifies the validity of the certificate against the host name.
|
||||
///
|
||||
@ -156,7 +156,7 @@ public:
|
||||
protected:
|
||||
void init();
|
||||
/// Extracts issuer and subject name from the certificate.
|
||||
|
||||
|
||||
static void* nid2oid(NID nid);
|
||||
/// Returns the OID for the given NID.
|
||||
|
||||
|
Reference in New Issue
Block a user