8#include "Arp/System/Commons/Net/IpAddress.hpp"
9#include "Arp/System/Commons/Net/Socket.hpp"
10#include "Arp/System/Commons/Logging.h"
11#include "Arp/System/Commons/Exceptions/Exceptions.h"
12#include "Arp/System/Commons/Security/IdentityStore.hpp"
13#include "Arp/System/Core/PimplPtr.hxx"
14#include "Arp/System/Commons/Net/TlsOptions.hpp"
19typedef struct ssl_st SSL;
20typedef struct ssl_ctx_st SSL_CTX;
23namespace Arp {
namespace System {
namespace Commons {
namespace Net
36using TlsContextPtr = std::shared_ptr<TlsContext>;
43 friend class TlsContext;
48 typedef std::shared_ptr<TlsSocket>
Ptr;
139 SocketError HandleSslResult(
int result,
int* sslErrorOut =
nullptr);
140 int GetFileDescriptor(
void);
141 void ClearOpenSslErrors(
void);
143 SocketError UpdateSessionKeysTls13(
bool requestUpdate =
true);
145 bool IsKeyUpdateScheduled()
const;
150 SSL* sslConnection =
nullptr;
151 TlsContextPtr pContext;
153 Ptr currentAcceptSocket;
157 bool socketIsConnected;
160 bool tlsConnectIsPending;
161 bool pendingTlsConnectNeedsRead;
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Derive from this class to inherit logging functionality.
Definition: Loggable.hxx:28
Unified representation for ip address schemes.
Definition: IpAddress.hpp:14
std::shared_ptr< Socket > Ptr
Contextual definition of pointer type.
Definition: Socket.hpp:122
Definition: TlsSocket.hpp:40
SocketError Close(void)
Closes the socket. This ends all communication on the socket.
Definition: TlsSocket.cpp:849
SocketError SetOptionUserTimeout(size_t timeout_ms)
Sets the retransmission timeout of a socket. This only works on Linux.
Definition: TlsSocket.cpp:398
SocketError GetOptionKeepAlive(bool &enabled)
Checks if keep-alive is enabled.
Definition: TlsSocket.cpp:292
SocketError SetOptionReuseAddress(bool enabled)
Enables/Disables the reuse-address option for this socket.
Definition: TlsSocket.cpp:253
SocketDomain GetSocketDomain(void)
Returns the type of the socket.
Definition: TlsSocket.cpp:120
std::shared_ptr< TlsSocket > Ptr
Contextual definition of pointer type.
Definition: TlsSocket.hpp:48
SocketError SetOptionNoDelay(bool enabled)
Enables/Disables no-delay for this socket.
Definition: TlsSocket.cpp:331
TlsSocket & operator=(const TlsSocket &arg)=delete
Assignment operator.
SocketError SetOptionBlocking(bool enable)
Enables/disables the blocking mode of this socket..
Definition: TlsSocket.cpp:494
bool Select(SelectMode mode, Microseconds timeout, SocketError &error)
Checks if an i/o operation can be performed without blocking the calling thread.
Definition: TlsSocket.cpp:947
SocketError GetSocketOption(SocketOptionName optionName, void *optionValue, size_t *optionLength)
Returns current value of queried socket option.
Definition: TlsSocket.cpp:238
SocketError SetSocketOption(SocketOptionName optionName, const void *optionValue, size_t optionLength)
Sets a single option on the socket.
Definition: TlsSocket.cpp:225
TlsSocket(SocketType type, SocketDomain domain, SocketBlockingMode blockingMode)
Constructs an TlsSocket instance.
Definition: TlsSocket.cpp:57
int Send(const void *pBuffer, size_t length, SocketError &error)
Transmit data over the socket that is in a connected state.
Definition: TlsSocket.cpp:874
SocketError Bind2(const IpAddress &ip4Address, int &port)
Binds the socket to a specific address and port combination.
Definition: TlsSocket.cpp:197
SocketError SetOptionKeepAliveProbeCount(int probeCount)
Sets the amount of probes to be sent, if the KeepAlive SocketOption is set to true.
Definition: TlsSocket.cpp:473
SocketError GetOptionLinger(bool &enable, size_t &timeout)
Returns the current linger options. For more information see Arp::System::Commons::Net::Socket::SetOp...
Definition: TlsSocket.cpp:374
SocketError Bind(const IpAddress &ip4Address, int port)
Binds the socket to a specific address and port combination.
Definition: TlsSocket.cpp:178
SocketError Shutdown(void)
Shuts down a full-duplex connection.
Definition: TlsSocket.cpp:801
int Receive(void *pBuffer, size_t length, SocketError &error)
Reads data from connected socket.
Definition: TlsSocket.cpp:910
SocketError GetOptionKeepAliveProbeCount(int &probeCount)
Gets the amount of probes to be sent, if the KeepAlive SocketOption is set to true....
Definition: TlsSocket.cpp:486
SocketError GetOptionKeepAliveProbeInterval(int &seconds)
Gets the interval time in between each Keep Alive probe, if the KeepAlive SocketOption is set to true...
Definition: TlsSocket.cpp:461
~TlsSocket(void)
Destructs this instance and frees all resouces.
Definition: TlsSocket.cpp:91
SocketError InitClient(const String &trustStoreName, const String &identityStoreName, const String &hostName)
Initializes this TLS socket in client mode. This method must be called before connecting to a server
Definition: TlsSocket.cpp:517
SocketError GetOptionUserTimeout(size_t &timeout_ms)
Gets the retransmission timeout of a socket. This only works on Linux. For more information see Arp::...
Definition: TlsSocket.cpp:411
SocketError SetOptionKeepAliveIdleTime(int seconds)
Sets the time that the socket needs to be idle for, before the Keep Alive mechanism can start if the ...
Definition: TlsSocket.cpp:423
int GetRemotePort(void)
If this socket is connected this method returns the port of the connection.
Definition: TlsSocket.cpp:146
SocketError RenegotiateSession()
Triggeres a complete renegotion of the esstablished TLS session
Definition: TlsSocket.cpp:1198
SocketError InitServer(const String &identityStoreName, const String &trustStoreName="")
Initializes this TLS socket in server mode. This method must be called before accepting connections w...
Definition: TlsSocket.cpp:553
bool IsBlocking(void)
Checks if the socket is in blocking mode.
Definition: TlsSocket.cpp:128
Arp::System::Ve::ISocketService ISocketService
Injection of SocketService-Interface in class context.
Definition: TlsSocket.hpp:51
bool IsTlsConnected(void)
Checks if a TLS connection is established with a remote peer.
Definition: TlsSocket.cpp:162
SocketError GetOptionKeepAliveIdleTime(int &seconds)
Gets the time that the socket needs to be idle for, before the Keep Alive mechanism can start if the ...
Definition: TlsSocket.cpp:436
int Poll(PollMode mode, Milliseconds timeout, SocketError &error)
Checks if an i/o operation can be processed without blocking.
Definition: TlsSocket.cpp:1025
SocketError SetOptionKeepAlive(bool enabled)
Enables/Disables the keep-alive option for this socket.
Definition: TlsSocket.cpp:280
SocketError SetOptionLinger(bool enable, size_t timeout)
Sets the amount of time a socket resides in TIME_WAIT state after active close.
Definition: TlsSocket.cpp:363
SocketError Connect(const IpAddress &ip4Address, int port)
Tries to connect with a remote socket.
Definition: TlsSocket.cpp:701
IpAddress GetRemoteIpAddress(void)
Checks if this socket is connected with a remote peer.
Definition: TlsSocket.cpp:136
bool IsConnected(void)
Checks if the socket is in blocking mode.
Definition: TlsSocket.cpp:154
Ptr Accept(IpAddress &ip4address, int &port, SocketError &error)
Accepts a pending connection request.
Definition: TlsSocket.cpp:594
TlsSocket(const TlsSocket &arg)=delete
Copy contructor.
SocketError SetOptionBroadcast(bool enabled)
Enables/Disables broadcast for this socket.
Definition: TlsSocket.cpp:305
SocketError GetOptionBroadcast(bool &enabled)
Checks if broadcast is enabled.
Definition: TlsSocket.cpp:317
SocketError UpdateSessionKeys(bool requestUpdate=true)
Update the keys for the current established TLS session
Definition: TlsSocket.cpp:1240
SocketError SetOptionKeepAliveProbeInterval(int seconds)
Sets the interval time in between each Keep Alive probe, if the KeepAlive SocketOption is set to true...
Definition: TlsSocket.cpp:448
SocketType GetSocketType(void)
Returns the type of the socket.
Definition: TlsSocket.cpp:112
void SetCipherList(String cipherList)
Sets the supported ciphers of this socket which are used during connection negotiation
Definition: TlsSocket.cpp:1177
SocketError Listen(size_t backlog)
Marks this socket as a passive socket that accepts incoming connection requests.
Definition: TlsSocket.cpp:213
SocketError GetPeerCertificate(Certificate &certificate)
Retrieves the certificate of the TLS peer
Definition: TlsSocket.cpp:1320
SocketError GetOptionReuseAddress(bool &enabled)
Checks if reuse-address is enabled.
Definition: TlsSocket.cpp:265
SocketError GetOptionNoDelay(bool &enabled)
Checks if no-delay is enabled.
Definition: TlsSocket.cpp:343
Class to handle x.509 certificates
Definition: Certificate.hpp:25
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: ChronoTypes.hpp:40
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: ChronoTypes.hpp:43
PollMode
This enum is used to specifiy the poll mode of the <cref name="Socket::Poll" > operation.
Definition: PollMode.hpp:15
SelectMode
Modes for Select call to check different data channels.
Definition: SelectMode.hpp:14
SocketDomain
Supported communication domains, selecting the protocol for communication.
Definition: SocketDomain.hpp:14
SocketType
Enumeration of supported socket types.
Definition: SocketType.hpp:14
ShutdownMode
This enum is used to specifiy the shutdown mode of the <cref name="Socket::Shutdown(ShutdownMode)" > ...
Definition: ShutdownMode.hpp:15
SocketError
Possible error codes for socket operation results.
Definition: SocketError.hpp:15
TlsOptions
This enum is used to select different options for the TlsSocket class
Definition: TlsOptions.hpp:25
SocketOptionName
Specifies socket options to be set by the application. Copied from Eclr Socket Adaption
Definition: SocketOptionName.hpp:17
SocketBlockingMode
Supported blocking modes.
Definition: Socket.hpp:28
Namespace for classes dealing with certificates
Root namespace for the PLCnext API