Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSSLSocket.h
Go to the documentation of this file.
1// @(#)root/net:$Id: TSSLSocket.h
2// Author: Alejandro Alvarez 16/09/2011
3
4/*************************************************************************
5 * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TSSLSocket
13#define ROOT_TSSLSocket
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TSSLSocket //
18// //
19// A TSocket wrapped in by SSL. //
20// //
21//////////////////////////////////////////////////////////////////////////
22
23#include "TSocket.h"
24
25typedef struct ssl_st SSL;
26typedef struct ssl_ctx_st SSL_CTX;
27
28class TSSLSocket : public TSocket {
29protected:
31
32private:
33 // CA, client cert/key... are class properties
34 static char fgSSLCAFile[];
35 static char fgSSLCAPath[];
36 static char fgSSLUCert[];
37 static char fgSSLUKey[];
38
39 // Object properties
42
43 void WrapWithSSL();
44
45public:
46 TSSLSocket(TInetAddress addr, const char *service, Int_t tcpwindowsize = -1);
47 TSSLSocket(TInetAddress addr, Int_t port, Int_t tcpwindowsize = -1);
48 TSSLSocket(const char *host, const char *service, Int_t tcpwindowsize = -1);
49 TSSLSocket(const char *url, Int_t port, Int_t tcpwindowsize = -1);
50 TSSLSocket(const char *sockpath);
51 TSSLSocket(Int_t desc);
52 TSSLSocket(Int_t desc, const char *sockpath);
53 TSSLSocket(const TSSLSocket &s);
54 virtual ~TSSLSocket();
55
56 void Close(Option_t *option="") override;
57
58 // Set up the SSL environment for the next instantiation
59 static void SetUpSSL(const char *cafile, const char *capath,
60 const char *ucert, const char *ukey);
61
62 // The rest of the Send and Recv calls rely ultimately on these,
63 // so it is enough to overload them
64 Int_t Recv(TMessage *&mess) override;
65 Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt = kDefault) override;
66 Int_t Send(const TMessage &mess) override;
67 Int_t SendRaw(const void *buffer, Int_t length,
68 ESendRecvOptions opt = kDefault) override;
69
70 // Issue with hidden method :(
71 Int_t Send(Int_t kind) override { return TSocket::Send(kind); }
72 Int_t Send(Int_t status, Int_t kind) override { return TSocket::Send(status, kind); }
73 Int_t Send(const char *mess, Int_t kind = kMESS_STRING) override { return TSocket::Send(mess, kind); }
74 Int_t Recv(Int_t &status, Int_t &kind) override { return TSocket::Recv(status, kind); }
75 Int_t Recv(char *mess, Int_t max) override { return TSocket::Recv(mess, max); }
76 Int_t Recv(char *mess, Int_t max, Int_t &kind) override { return TSocket::Recv(mess, max, kind); }
77
78 ClassDefOverride(TSSLSocket,0) // SSL wrapped socket
79};
80
81#endif
@ kMESS_STRING
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
struct ssl_ctx_st SSL_CTX
Definition TSSLSocket.h:26
struct ssl_st SSL
Definition TSSLSocket.h:25
ESendRecvOptions
Definition TSystem.h:226
@ kDefault
Definition TSystem.h:227
This class represents an Internet Protocol (IP) address.
Int_t Send(Int_t kind) override
Send a single message opcode.
Definition TSSLSocket.h:71
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Send a raw buffer of specified length.
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault) override
Receive a raw buffer of specified length bytes.
SSL * fSSL
Definition TSSLSocket.h:41
Int_t Send(const char *mess, Int_t kind=kMESS_STRING) override
Send a character string buffer.
Definition TSSLSocket.h:73
SSL_CTX * fSSLCtx
Definition TSSLSocket.h:40
static char fgSSLUKey[]
Definition TSSLSocket.h:37
void Close(Option_t *option="") override
Close the SSL connection.
static char fgSSLCAPath[]
Definition TSSLSocket.h:35
Int_t Recv(TMessage *&mess) override
Receive a TMessage object.
void WrapWithSSL()
Wraps the socket with OpenSSL.
static char fgSSLCAFile[]
Definition TSSLSocket.h:34
static char fgSSLUCert[]
Definition TSSLSocket.h:36
Int_t Recv(char *mess, Int_t max) override
Receive a character string message of maximum max length.
Definition TSSLSocket.h:75
Int_t Send(Int_t status, Int_t kind) override
Send a status and a single message opcode.
Definition TSSLSocket.h:72
Int_t Recv(char *mess, Int_t max, Int_t &kind) override
Receive a character string message of maximum max length.
Definition TSSLSocket.h:76
virtual ~TSSLSocket()
Close gracefully the connection, and free SSL structures.
Int_t Recv(Int_t &status, Int_t &kind) override
Receives a status and a message type.
Definition TSSLSocket.h:74
Int_t Send(const TMessage &mess) override
Send a TMessage object.
static void SetUpSSL(const char *cafile, const char *capath, const char *ucert, const char *ukey)
Set up the static configuration variables.
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition TSocket.cxx:818
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition TSocket.cxx:522
struct ssl_ctx_st SSL_CTX
struct ssl_st SSL