Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:26:23

0001 // @(#)root/net:$Id: TSSLSocket.h
0002 // Author: Alejandro Alvarez 16/09/2011
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TSSLSocket
0013 #define ROOT_TSSLSocket
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TSSLSocket                                                           //
0018 //                                                                      //
0019 // A TSocket wrapped in by SSL.                                         //
0020 //                                                                      //
0021 //////////////////////////////////////////////////////////////////////////
0022 
0023 #include "TSocket.h"
0024 
0025 namespace ROOT::Deprecated {
0026 
0027 typedef struct ssl_st     SSL;
0028 typedef struct ssl_ctx_st SSL_CTX;
0029 
0030 class TSSLSocket : public TSocket {
0031 protected:
0032    TSSLSocket() : TSocket() {}
0033 
0034 private:
0035    // CA, client cert/key... are class properties
0036    static char fgSSLCAFile[];
0037    static char fgSSLCAPath[];
0038    static char fgSSLUCert[];
0039    static char fgSSLUKey[];
0040 
0041    // Object properties
0042    SSL_CTX *fSSLCtx;
0043    SSL     *fSSL;
0044 
0045    void WrapWithSSL();
0046 
0047 public:
0048    TSSLSocket(TInetAddress addr, const char *service, Int_t tcpwindowsize = -1);
0049    TSSLSocket(TInetAddress addr, Int_t port, Int_t tcpwindowsize = -1);
0050    TSSLSocket(const char *host, const char *service, Int_t tcpwindowsize = -1);
0051    TSSLSocket(const char *url, Int_t port, Int_t tcpwindowsize = -1);
0052    TSSLSocket(const char *sockpath);
0053    TSSLSocket(Int_t desc);
0054    TSSLSocket(Int_t desc, const char *sockpath);
0055    TSSLSocket(const TSSLSocket &s);
0056    virtual ~TSSLSocket();
0057 
0058    void Close(Option_t *option="") override;
0059 
0060    // Set up the SSL environment for the next instantiation
0061    static void SetUpSSL(const char *cafile, const char *capath,
0062                         const char *ucert,  const char *ukey);
0063 
0064    // The rest of the Send and Recv calls rely ultimately on these,
0065    // so it is enough to overload them
0066    Int_t Recv(TMessage *&mess) override;
0067    Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt = kDefault) override;
0068    Int_t Send(const TMessage &mess) override;
0069    Int_t SendRaw(const void *buffer, Int_t length,
0070                  ESendRecvOptions opt = kDefault) override;
0071 
0072    // Issue with hidden method :(
0073    Int_t Send(Int_t kind) override                         { return TSocket::Send(kind); }
0074    Int_t Send(Int_t status, Int_t kind) override           { return TSocket::Send(status, kind); }
0075    Int_t Send(const char *mess, Int_t kind = kMESS_STRING) override { return TSocket::Send(mess, kind); }
0076    Int_t Recv(Int_t &status, Int_t &kind) override         { return TSocket::Recv(status, kind); }
0077    Int_t Recv(char *mess, Int_t max) override              { return TSocket::Recv(mess, max); }
0078    Int_t Recv(char *mess, Int_t max, Int_t &kind) override { return TSocket::Recv(mess, max, kind); }
0079 
0080    ClassDefOverride(TSSLSocket,0)  // SSL wrapped socket
0081 };
0082 
0083 } // namespace ROOT::Deprecated
0084 
0085 using TSSLSocket R__DEPRECATED(6, 42,
0086                                "ROOT is not providing an SSL socket API anymore. "
0087                                "Consider using SSH tunneling for secure channels.") = ROOT::Deprecated::TSSLSocket;
0088 
0089 #endif