1#if defined(HAVE_CONFIG_H)
19#define RESIPROCATE_SUBSYSTEM Subsystem::TRANSPORT
27 const Data& interfaceObj,
29 const Data& sipDomain,
34 unsigned transportFlags,
37 const Data& certificateFilename,
38 const Data& privateKeyFilename,
39 const Data& privateKeyPassPhrase) :
40 TcpBaseTransport(fifo, portNum, version, interfaceObj, socketFunc, compression, transportFlags),
44 mClientVerificationMode(cvm),
45 mUseEmailAsSIP(useEmailAsSIP),
46 mCertificateFilename(certificateFilename),
47 mPrivateKeyFilename(privateKeyFilename),
48 mPrivateKeyPassPhrase(privateKeyPassPhrase),
49 mReloadCertificate(false)
58 if(!sipDomain.
empty())
63 DebugLog(<<
"Using SecurityTypes::DynamicTLS");
66 DebugLog(<<
"Using SecurityTypes::TLSv1");
69 throw invalid_argument(
"Unrecognised SecurityTypes::SSLType value");
76TlsBaseTransport::createDomainCtx()
86 SSL_CTX_set_min_proto_version(ctx, TLS1_VERSION);
87 SSL_CTX_set_max_proto_version(ctx, TLS1_VERSION);
89 if(mCertVerifyCallback)
91 SSL_CTX_set_cert_verify_callback(ctx, mCertVerifyCallback, mCertVerifyCallbackArg);
98TlsBaseTransport::reloadDomainCtx()
107 DebugLog(<<
"TlsBaseTransport::reloadDomainCtx, re-reading certificate and private key for domain " <<
tlsDomain());
111 ctx = createDomainCtx();
115 ErrLog(<<
"Failed to reload the certificate/private key for domain " <<
tlsDomain() <<
", still using the previous ones: " << e);
120 ErrLog(<<
"Failed to reload the certificate/private key for domain " <<
tlsDomain() <<
", still using the previous ones");
125 ErrLog(<<
"Failed to reload the certificate/private key for domain " <<
tlsDomain() <<
", still using the previous ones");
133 InfoLog(<<
"Reloaded the certificate and private key for domain " <<
tlsDomain());
148 DebugLog(<<
"TlsBaseTransport::onReload, setting mReloadCertificate for domain " <<
tlsDomain());
168 DebugLog(<<
"Using TlsDomain-transport SSL_CTX");
173 DebugLog(<<
"Using SecurityTypes::DynamicTLS (dynamic version negotiation)");
178 DebugLog(<<
"Using SecurityTypes::TLSv1 (pinned to TLSv1; 1.0 only)");
191 ErrLog(<<
"refusing to set SSL callback for unknown SSL stack vendor");
197 mCertVerifyCallback = (int (*)(X509_STORE_CTX *,
void *))func;
198 mCertVerifyCallbackArg = arg;
199 SSL_CTX_set_cert_verify_callback(
getCtx(), mCertVerifyCallback, mCertVerifyCallbackArg);
struct ssl_ctx_st SSL_CTX
#define resip_assert_not_null(x)
Handles cross-platform sockets compatibility.
The abstract base-class for all exceptions thrown by resip code.
Connection implements, via sockets, ConnectionBase for managed connections.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
bool empty() const noexcept
Checks whether the Data is empty.
A templated, threadsafe message-queue class.
virtual SSL_CTX * createDomainCtx(const SSL_METHOD *method, const Data &domain, const Data &certificateFilename, const Data &privateKeyFilename, const Data &privateKeyPassPhrase)
Throws BaseSecurity::Exception if the certificate or private key can't be loaded; nothing is left all...
virtual void init()
Performs constructor activities that depend on virtual functions specified by derived classes.
std::atomic< bool > mReloadCertificate
bool setPeerCertificateVerificationCallback(SecurityTypes::SSLVendor vendor, void *func, void *arg)
Set a custom callback function to be used by the SSL stack to inspect the peer certificate.
const Data mPrivateKeyPassPhrase
SecurityTypes::SSLType mSslType
TlsBaseTransport(Fifo< TransactionMessage > &fifo, int portNum, IpVersion version, const Data &interfaceObj, Security &security, const Data &sipDomain, SecurityTypes::SSLType sslType, TransportType transportType, AfterSocketCreationFuncPtr socketFunc=0, Compression &compression=Compression::Disabled, unsigned transportFlags=0, SecurityTypes::TlsClientVerificationMode cvm=SecurityTypes::None, bool useEmailAsSIP=false, const Data &certificateFilename="", const Data &privateKeyFilename="", const Data &privateKeyPassPhrase="")
const Data mPrivateKeyFilename
const Data mCertificateFilename
virtual ~TlsBaseTransport()
Connection * createConnection(const Tuple &who, Socket fd, bool server=false)
Makes new Connection using provided socket.
void setTlsDomain(const Data &domain)
Compression & mCompression
const Data & tlsDomain() const
Represents a network address.
void setType(TransportType type)
This file is used to handle compatibility fixes/tweaks so reSIProcate can function on multiple platfo...
TlsClientVerificationMode
SSLType
Note: Before adding to the SSLType enum, please see the comments about mTlsCtx in resip/stack/ssl/Sec...
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)
TransportType
An enumeration of transport protocols.
IpVersion
An enumeration of IP versions.