VR-Link API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlInetTlsSocket.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2026 MAK Technologies, Inc
3 ** All rights reserved.
4 *********************************************************************/
8 #pragma once
9 
10 #include <vlutil/vlInetTcpSocket.h>
11 #include <vlutil/vlString.h>
12 
13 #ifdef DtUSE_UTILITIES_NAMESPACE
14 namespace DtUSE_UTILITIES_NAMESPACE
15 {
16 #endif
17 
18 class DtFilename;
19 
21 {
22 public:
23 
25 
41  DtInetTlsSocket( DtU16 localPort, DtInetDevice* hostIf = nullptr,
43  bool immediateOpen = true );
44 
72  DtInetTlsSocket(const DtInetEndpoint& dest, DtU16 localPort = 0, DtInetDevice* hostIf = nullptr,
73  DtU32 flags = DtDefaultSockOpts, bool immediateOpen = true);
74 
75  virtual ~DtInetTlsSocket();
76 
78 
79  virtual bool setSocket(const DtInetEndpoint& dest, DtU16 localPort = 0, DtInetDevice* hostIf = nullptr,
80  DtU32 flags = DtDefaultSockOpts) override;
81  virtual bool setDestination( const DtInetEndpoint& addr ) override;
82  virtual bool openSocket() override;
83  virtual bool closeSocket() override;
84 
85  virtual bool listenForConnections() override;
86  virtual bool acceptConnection(DtInetTcpSocket* peer, DtU32 flags = DtDefaultSockOpts) override;
87 
88  virtual int send(caddr_t packet, size_t size, DtU32 flags = 0) override;
89  virtual int sendTo(caddr_t packet, size_t size, DtInetEndpoint& dest, DtU32 flags = 0) override;
90  virtual int sendChain(DtInetBufferChain& packets, DtU32 flags = 0) override;
91  virtual int sendChainTo(DtInetBufferChain& packets, DtInetEndpoint& dest, DtU32 flags = 0) override;
92 
93  virtual DtInetSockRcvStatus recv(caddr_t buff, size_t buffSize, DtU32 flags = 0) override;
94  virtual DtInetSockRcvStatus recvToChain(DtInetBufferChain& packets, DtU32 flags = 0) override;
95  virtual DtInetSockRcvStatus recvFrom(caddr_t buff, size_t buffSize, DtInetEndpoint& src, DtU32 flags = 0) override;
96  virtual DtInetSockRcvStatus recvToChainFrom(DtInetBufferChain& packets, DtInetEndpoint& src, DtU32 flags = 0) override;
97 
98  virtual unsigned descriptor() const override;
100 
103  virtual bool handshakeDestination();
104 
105 public:
106 
107  // Static configuration accessors for TLS defaults
109  static void setServerCRT(const DtString& crt);
110  static const DtString& serverCRT();
111 
112  static void setServerKey(const DtString& key);
113  static const DtString& serverKey();
114 
115  static void setClientCRT(const DtString& crt);
116  static const DtString& clientCRT();
117 
118  static void setClientKey(const DtString& key);
119  static const DtString& clientKey();
120 
121  static void setCaCRT(const DtString& crt);
122  static const DtString& caCRT();
123 
124  static void setCertificateFolder(const DtString& folder);
125  static const DtString& certificateFolder();
126 
127  static void setClientCertRequired(bool required);
128  static bool clientCertRequired();
130 
131  protected:
132 
134  virtual bool initSslForListening();
135 
136  // Initialize client-side SSL context if not already present. Returns true on success.
137  virtual bool initClientSslContext();
138 
142  virtual bool buildCertificateFilePath(DtFilename& certFilename);
143 
144  protected:
145 
147 
148  void* mySslContext; // boost::asio::ssl::context*
149  void* mySslStream; // boost::asio::ssl::stream<boost::asio::ip::tcp::socket>*
151 
156 
160 
161  protected:
162 
166 
177 
180 
181 };
182 
183 #ifdef DtUSE_UTILITIES_NAMESPACE
184 } // end namespace DtUSE_UTILITIES_NAMESPACE
185 #endif
static DtString theCaCRT
Static members for default certificate paths and client cert requirement.
Definition: vlInetTlsSocket.h:171
static bool theClientCertRequired
Wheter server sockets require client certificates for mutual authentication. Default is true...
Definition: vlInetTlsSocket.h:179
static DtString theClientCRT
Static members for default certificate paths and client cert requirement.
Definition: vlInetTlsSocket.h:169
Definition: vlInetAddrUtils.h:58
void * mySslStream
opaque handles to avoid exposing boost types in header
Definition: vlInetTlsSocket.h:149
Contains the DtString class declaration.
DtInetSockRcvStatus
Socket state enumeration.
Definition: vlInetSocket.h:129
This file contains the declaration of the DtInetTcpSocket base class.
static DtString theClientKey
Static members for default certificate paths and client cert requirement.
Definition: vlInetTlsSocket.h:170
std::vector< DtInetBuffer * > DtInetBufferChain
Socket state enumeration.
Definition: vlInetSocket.h:105
void * mySslContext
opaque handles to avoid exposing boost types in header
Definition: vlInetTlsSocket.h:148
int recv(int s, char *buf, int bufLen, int flags)
static DtString theServerKey
Static members for default certificate paths and client cert requirement.
Definition: vlInetTlsSocket.h:168
#define DtSockOptNoDelay
Tell TCP sockets to disable Nagle packet coalescing and enables TCP_NODELAY operation.
Definition: vlInetSocket.h:65
DtInetAddrFamily
Definition: vlInetAddrUtils.h:55
The DtInetEndpoint class provides a protocol independant, address family independent mechanism to rep...
Definition: vlInetEndpoint.h:34
bool myOwnContext
Track whether we own the SSL context (i.e., should delete it in destructor) Accepted client sockets w...
Definition: vlInetTlsSocket.h:159
bool myStreamIsOpen
Track whether the SSL stream is currently open (i.e., handshake completed).
Definition: vlInetTlsSocket.h:155
static DtString theCertificateFolder
Folder to prepend to certificate file names if the file name is relative.
Definition: vlInetTlsSocket.h:175
Definition: vlInetDevice.h:101
Instances of DtFilename are DtStrings which convert filenames to the native format.
Definition: vlFilename.h:20
Definition: vlInetTlsSocket.h:20
unsigned short DtU16
A 16 bit unsigned integer value.
Definition: vlMachineTypes.h:152
static DtString theServerCRT
Static members for default certificate paths and client cert requirement.
Definition: vlInetTlsSocket.h:167
int send(int s, char *buf, int bufLen, int flags)
unsigned long DtU32
A 32 bit unsigned integer value.
Definition: vlMachineTypes.h:165
Instances of DtString are used to represent strings.
Definition: vlString.h:38
The DtInetSocket class provides an address family independent stream socket.
Definition: vlInetTcpSocket.h:23
#define DtDefaultSockOpts
Marks the Socket as Writable.
Definition: vlInetSocket.h:90
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:121

Document ID: Generated on Mon Sep 28 00:09:32 EDT 2026 from SVN revision 295353
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)