ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TSocket
24 #include "TSocket.h"
25 #endif
26 
27 typedef struct ssl_st SSL;
28 typedef struct ssl_ctx_st SSL_CTX;
29 
30 class TSSLSocket : public TSocket {
31 protected:
33 
34 private:
35  // CA, client cert/key... are class properties
36  static char fgSSLCAFile[];
37  static char fgSSLCAPath[];
38  static char fgSSLUCert[];
39  static char fgSSLUKey[];
40 
41  // Object properties
44 
45  void WrapWithSSL();
46 
47 public:
48  TSSLSocket(TInetAddress addr, const char *service, Int_t tcpwindowsize = -1);
49  TSSLSocket(TInetAddress addr, Int_t port, Int_t tcpwindowsize = -1);
50  TSSLSocket(const char *host, const char *service, Int_t tcpwindowsize = -1);
51  TSSLSocket(const char *url, Int_t port, Int_t tcpwindowsize = -1);
52  TSSLSocket(const char *sockpath);
53  TSSLSocket(Int_t desc);
54  TSSLSocket(Int_t desc, const char *sockpath);
55  TSSLSocket(const TSSLSocket &s);
56  virtual ~TSSLSocket();
57 
58  void Close(Option_t *option="");
59 
60  // Set up the SSL environment for the next instantiation
61  static void SetUpSSL(const char *cafile, const char *capath,
62  const char *ucert, const char *ukey);
63 
64  // The rest of the Send and Recv calls rely ultimately on these,
65  // so it is enough to overload them
66  Int_t Recv(TMessage *&mess);
68  Int_t Send(const TMessage &mess);
69  Int_t SendRaw(const void *buffer, Int_t length,
71 
72  // Issue with hidden method :(
73  Int_t Send(Int_t kind) { return TSocket::Send(kind); }
74  Int_t Send(Int_t status, Int_t kind) { return TSocket::Send(status, kind); }
75  Int_t Send(const char *mess, Int_t kind = kMESS_STRING) { return TSocket::Send(mess, kind); }
76  Int_t Recv(Int_t &status, Int_t &kind) { return TSocket::Recv(status, kind); }
77  Int_t Recv(char *mess, Int_t max) { return TSocket::Recv(mess, max); }
78  Int_t Recv(char *mess, Int_t max, Int_t &kind) { return TSocket::Recv(mess, max, kind); }
79 
80  ClassDef(TSSLSocket,0) // SSL wrapped socket
81 };
82 
83 #endif
SSL * fSSL
Definition: TSSLSocket.h:43
static char fgSSLUCert[]
Definition: TSSLSocket.h:38
tuple buffer
Definition: tree.py:99
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Definition: TSSLSocket.cxx:263
static char fgSSLCAPath[]
Definition: TSSLSocket.h:37
const char Option_t
Definition: RtypesCore.h:62
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition: TSocket.cxx:520
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition: TSocket.cxx:818
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:40
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
int Int_t
Definition: RtypesCore.h:41
ESendRecvOptions
Definition: TSocket.h:65
Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition: TSSLSocket.cxx:189
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition: TSSLSocket.cxx:254
Int_t Send(const char *mess, Int_t kind=kMESS_STRING)
Send a character string buffer.
Definition: TSSLSocket.h:75
static char fgSSLUKey[]
Definition: TSSLSocket.h:39
Int_t Recv(char *mess, Int_t max, Int_t &kind)
Receive a character string message of maximum max length.
Definition: TSSLSocket.h:78
Int_t Send(Int_t kind)
Send a single message opcode.
Definition: TSSLSocket.h:73
SSL_CTX * fSSLCtx
Definition: TSSLSocket.h:42
struct ssl_st SSL
Definition: civetweb.c:389
Double_t length(const TVector2 &v)
Definition: CsgOps.cxx:347
Int_t Send(Int_t status, Int_t kind)
Send a status and a single message opcode.
Definition: TSSLSocket.h:74
static void SetUpSSL(const char *cafile, const char *capath, const char *ucert, const char *ukey)
Set up the static configuration variables.
Definition: TSSLSocket.cxx:174
void Close(Option_t *option="")
Close the SSL connection.
Definition: TSSLSocket.cxx:164
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
void WrapWithSSL()
Wraps the socket with OpenSSL.
Definition: TSSLSocket.cxx:35
struct ssl_ctx_st SSL_CTX
Definition: civetweb.c:391
Int_t Recv(char *mess, Int_t max)
Receive a character string message of maximum max length.
Definition: TSSLSocket.h:77
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
Definition: TSSLSocket.cxx:198
Int_t Recv(Int_t &status, Int_t &kind)
Receives a status and a message type.
Definition: TSSLSocket.h:76
static char fgSSLCAFile[]
Definition: TSSLSocket.h:36
virtual ~TSSLSocket()
Close gracefully the connection, and free SSL structures.
Definition: TSSLSocket.cxx:152