21#include <openssl/ssl.h>
40 std::cout <<
"-- ssl_info_callback: error occurred.\n";
44 std::cout <<
" - " << SSL_state_string_long(ssl);
45 std::cout <<
" - " << SSL_state_string(ssl);
46 std::cout << std::endl;
58 if (!(
fSSLCtx = SSL_CTX_new(SSLv23_method()))) {
59 Error(
"WrapWithSSL",
"the context could not be created");
64 Error(
"WrapWithSSL",
"could not set the CA file and/or the CA path");
69 Error(
"WrapWithSSL",
"could not set the client certificate");
74 Error(
"WrapWithSSL",
"could not set the client private key");
80 Error(
"WrapWithSSL",
"cannot create the ssl struct");
89 Error(
"WrapWithSSL",
"cannot bind to the socket %d",
fSocket);
94 if (SSL_connect(
fSSL) != 1) {
95 Error(
"WrapWithSSL",
"cannot connect");
112 :
TSocket(addr, service, tcpwindowsize)
120 :
TSocket(addr, port, tcpwindowsize)
128 :
TSocket(host, service, tcpwindowsize)
136 :
TSocket(url, port, tcpwindowsize)
195 const char *ucert,
const char *ukey)
211 Error(
"Recv",
"not implemented");
223 if (length == 0)
return 0;
229 Int_t remain = length;
234 n = SSL_peek(
fSSL, (
char*)buffer + offset, (
int)remain);
236 n = SSL_read(
fSSL, (
char*)buffer + offset, (
int)remain);
240 Error(
"RecvRaw",
"failed to read from the socket");
245 SSL_set_quiet_shutdown(
fSSL, 1);
258 if (opt ==
kPeek)
return n;
276 Error(
"Send",
"not implemented");
292 if ((nsent = SSL_write(
fSSL, buffer, (
int)length)) <= 0) {
int Int_t
Signed integer 4 bytes (int).
const char Option_t
Option string (const char).
void ssl_info_callback(const SSL *ssl, int where, int ret)
static void ssl_info_callback(const SSL *ssl, int what, int ret)
This class represents an Internet Protocol (IP) address.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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.
void Close(Option_t *option="") override
Close the SSL connection.
static char fgSSLCAPath[]
Int_t Recv(TMessage *&mess) override
Receive a TMessage object.
void WrapWithSSL()
Wraps the socket with OpenSSL.
static char fgSSLCAFile[]
virtual ~TSSLSocket()
Close gracefully the connection, and free SSL structures.
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.
static ULong64_t fgBytesRecv
virtual void Close(Option_t *opt="")
Close the socket.
static ULong64_t fgBytesSent
static void ResetErrno()
Static function resetting system error number.
#define SSL_ERROR_SYSCALL
#define SSL_ERROR_ZERO_RETURN