30 #include <sys/types.h>
33 #include <sys/socket.h>
35 #include <netinet/in.h>
45 #include <ksslcertdlg.h>
46 #include <tdemessagebox.h>
48 #include <kresolver.h>
51 #include <tdelocale.h>
52 #include <dcopclient.h>
53 #include <tqcstring.h>
54 #include <tqdatastream.h>
56 #include <tdeapplication.h>
58 #include <tdeprotocolmanager.h>
61 #include "tdeio/tcpslavebase.h"
63 using namespace TDEIO;
65 class TCPSlaveBase::TcpSlaveBasePrivate
69 TcpSlaveBasePrivate() : rblockSz(256), militantSSL(false), userAborted(false) {}
70 ~TcpSlaveBasePrivate() {}
74 KSSLCertificateCache *cc;
86 bool needSSLHandShake;
94 TCPSlaveBase::TCPSlaveBase(
unsigned short int defaultPort,
95 const TQCString &protocol,
96 const TQCString &poolSocket,
97 const TQCString &appSocket)
98 :
SlaveBase (protocol, poolSocket, appSocket),
100 m_iDefaultPort(defaultPort),
101 m_sServiceName(protocol),
106 doConstructorStuff();
110 TCPSlaveBase::TCPSlaveBase(
unsigned short int defaultPort,
111 const TQCString &protocol,
112 const TQCString &poolSocket,
113 const TQCString &appSocket,
115 :
SlaveBase (protocol, poolSocket, appSocket),
118 m_iDefaultPort(defaultPort),
119 m_sServiceName(protocol),
122 doConstructorStuff();
124 m_bIsSSL = initializeSSL();
128 void TCPSlaveBase::doConstructorStuff()
130 d =
new TcpSlaveBasePrivate;
140 d->useSSLTunneling =
false;
143 TCPSlaveBase::~TCPSlaveBase()
146 if (d->usingTLS)
delete d->kssl;
147 if (d->dcc)
delete d->dcc;
148 if (d->pkcs)
delete d->pkcs;
155 if ( (m_bIsSSL || d->usingTLS) && !d->useSSLTunneling )
157 if ( d->needSSLHandShake )
158 (void) doSSLHandShake(
true );
159 return d->kssl->write(
data, len);
161 return KSocks::self()->write(m_iSock,
data, len);
170 if ( (m_bIsSSL || d->usingTLS) && !d->useSSLTunneling )
172 if ( d->needSSLHandShake )
173 (void) doSSLHandShake(
true );
174 return d->kssl->read(
data, len);
176 return KSocks::self()->read(m_iSock,
data, len);
209 if ((m_bIsSSL || d->usingTLS) && !d->useSSLTunneling) {
210 if ( d->needSSLHandShake )
211 (void) doSSLHandShake(
true );
213 while (clen < len-1) {
214 rc = d->kssl->pending();
217 if (bytes > d->rblockSz)
220 rc = d->kssl->peek(tmpbuf, bytes);
227 for (
int i = 0; i < rc; i++) {
228 if (tmpbuf[i] ==
'\n') {
234 if (bytes+clen >= len)
235 bytes = len - clen - 1;
237 rc = d->kssl->read(buf, bytes);
248 rc = d->kssl->read(buf, 1);
262 while (clen < len-1) {
264 rc = KSocks::self()->read(m_iSock, buf, 1);
286 unsigned short int p = _p;
307 unsigned short int p;
310 d->userAborted =
false;
313 if (
metaData(
"main_frame_request") ==
"TRUE" &&
314 metaData(
"ssl_activate_warnings") ==
"TRUE" &&
315 metaData(
"ssl_was_in_use") ==
"TRUE" &&
318 if (kss.warnOnLeave()) {
319 int result =
messageBox( i18n(
"You are about to leave secure "
320 "mode. Transmissions will no "
321 "longer be encrypted.\nThis "
322 "means that a third party could "
323 "observe your data in transit."),
324 WarningContinueCancel,
325 i18n(
"Security Information"),
326 i18n(
"C&ontinue Loading"), TQString::null,
327 "WarnOnLeaveSSLMode" );
330 TDEConfig *
config =
new TDEConfig(
"tdeioslaverc");
331 config->setGroup(
"Notification Messages");
333 if (!
config->readBoolEntry(
"WarnOnLeaveSSLMode",
true)) {
334 config->deleteEntry(
"WarnOnLeaveSSLMode");
336 kss.setWarnOnLeave(
false);
341 if ( result == KMessageBox::Cancel ) {
342 d->userAborted =
true;
350 d->needSSLHandShake = m_bIsSSL;
352 ks.setAddress(host, p);
353 if ( d->timeout > -1 )
354 ks.setTimeout( d->timeout );
356 if (ks.connect() < 0)
358 d->status = ks.status();
361 if (d->status == IO_LookupError)
362 error( ERR_UNKNOWN_HOST, host);
363 else if ( d->status != -1 )
364 error( ERR_COULD_NOT_CONNECT, host);
372 const TDESocketAddress *sa = ks.peerAddress();
374 d->ip = sa->nodeName();
380 if ( d->block != ks.blockingMode() )
381 ks.setBlockingMode( d->block );
385 if (m_bIsSSL && !d->useSSLTunneling) {
386 if ( !doSSLHandShake( sendError ) )
395 if ((fp = KDE_fdopen(m_iSock,
"w+")) == 0) {
427 if (KSSL::doesSSLWork()) {
443 d->militantSSL =
false;
453 if (d->usingTLS || d->useSSLTunneling || m_bIsSSL || !KSSL::doesSSLWork())
456 d->kssl =
new KSSL(
false);
457 if (!d->kssl->TLSInit()) {
462 if ( !d->realHost.isEmpty() )
464 kdDebug(7029) <<
"Setting real hostname: " << d->realHost << endl;
465 d->kssl->setPeerHost(d->realHost);
467 kdDebug(7029) <<
"Setting real hostname: " << d->host << endl;
468 d->kssl->setPeerHost(d->host);
472 KSSLSession *s = KSSLSession::fromString(
metaData(
"ssl_session_id"));
474 d->kssl->takeSession(s);
480 int rc = d->kssl->connect(m_iSock);
486 setMetaData(
"ssl_session_id", d->kssl->session()->toString());
491 if (!d->kssl->reusingSession()) {
492 rc = verifyCertificate();
501 d->savedMetaData = mOutgoingMetaData;
502 return (d->usingTLS ? 1 : 0);
517 if (!(d->usingTLS || d->useSSLTunneling || m_bIsSSL))
520 mOutgoingMetaData = d->savedMetaData;
526 if (m_bIsSSL || d->needSSLHandShake || !KSSL::doesSSLWork())
534 void TCPSlaveBase::certificatePrompt()
537 bool send =
false, prompt =
false, save =
false, forcePrompt =
false;
538 KSSLCertificateHome::KSSLAuthAction aa;
542 if (
metaData(
"ssl_no_client_cert") ==
"TRUE")
return;
543 forcePrompt = (
metaData(
"ssl_force_cert_prompt") ==
"TRUE");
551 if (!d->kssl)
return;
555 certname = KSSLCertificateHome::getDefaultCertificateName(&aa);
557 case KSSLCertificateHome::AuthSend:
558 send =
true; prompt =
false;
560 case KSSLCertificateHome::AuthDont:
561 send =
false; prompt =
false;
562 certname = TQString::null;
564 case KSSLCertificateHome::AuthPrompt:
565 send =
false; prompt =
true;
573 if (!d->realHost.isEmpty()) {
574 ourHost = d->realHost;
580 TQString tmpcn = KSSLCertificateHome::getDefaultCertificateName(ourHost, &aa);
581 if (aa != KSSLCertificateHome::AuthNone) {
583 case KSSLCertificateHome::AuthSend:
588 case KSSLCertificateHome::AuthDont:
591 certname = TQString::null;
593 case KSSLCertificateHome::AuthPrompt:
605 certname =
metaData(
"ssl_demand_certificate");
606 if (!certname.isEmpty()) {
613 if (certname.isEmpty() && !prompt && !forcePrompt)
return;
616 if (prompt || forcePrompt) {
617 TQStringList certs = KSSLCertificateHome::getCertificateList();
619 for (TQStringList::Iterator it = certs.begin(); it != certs.end(); ++it) {
620 KSSLPKCS12 *pkcs = KSSLCertificateHome::getCertificateByName(*it);
621 if (pkcs && (!pkcs->getCertificate() ||
622 !pkcs->getCertificate()->x509V3Extensions().certTypeSSLClient())) {
628 if (certs.isEmpty())
return;
631 d->dcc =
new DCOPClient;
633 if (!d->dcc->isApplicationRegistered(
"tdeio_uiserver")) {
634 TDEApplication::startServiceByDesktopPath(
"tdeio_uiserver.desktop",
639 TQByteArray
data, retval;
641 TQDataStream arg(
data, IO_WriteOnly);
644 arg <<
metaData(
"window-id").toInt();
645 bool rc = d->dcc->call(
"tdeio_uiserver",
"UIServer",
646 "showSSLCertDialog(TQString, TQStringList,int)",
647 data, rettype, retval);
649 if (rc && rettype ==
"KSSLCertDlgRet") {
650 TQDataStream retStream(retval, IO_ReadOnly);
656 certname = drc.choice;
665 KSSLCertificateHome::setDefaultCertificate(certname, ourHost,
672 KSSLPKCS12 *pkcs = KSSLCertificateHome::getCertificateByName(certname);
673 if (!pkcs && KSSLCertificateHome::hasCertificateByName(certname)) {
677 ai.
prompt = i18n(
"Enter the certificate password:");
678 ai.
caption = i18n(
"SSL Certificate Password");
679 ai.
url.setProtocol(
"kssl");
680 ai.
url.setHost(certname);
691 i18n(
"Unable to open the certificate. Try a new password?")))
696 pkcs = KSSLCertificateHome::getCertificateByName(certname, ai.
password);
703 if (!d->kssl->setClientCertificate(pkcs)) {
704 messageBox(Information, i18n(
"The procedure to set the "
705 "client certificate for the session "
706 "failed."), i18n(
"SSL"));
710 kdDebug(7029) <<
"Client SSL certificate is being used." << endl;
713 KSSLCertificateHome::setDefaultCertificate(certname, ourHost,
736 int TCPSlaveBase::verifyCertificate()
739 bool permacache =
false;
740 bool isChild =
false;
741 bool _IPmatchesCN =
false;
743 bool doAddHost =
false;
746 if (!d->realHost.isEmpty())
747 ourHost = d->realHost;
748 else ourHost = d->host;
750 TQString theurl = TQString(m_sServiceName)+
"://"+ourHost+
":"+TQString::number(m_iPort);
753 d->militantSSL =
false;
754 else if (
metaData(
"ssl_militant") ==
"TRUE")
755 d->militantSSL =
true;
757 if (!d->cc) d->cc =
new KSSLCertificateCache;
759 KSSLCertificate& pc = d->kssl->peerInfo().getPeerCertificate();
761 KSSLCertificate::KSSLValidationList ksvl = pc.validateVerbose(KSSLCertificate::SSLServer);
763 _IPmatchesCN = d->kssl->peerInfo().certMatchesAddress();
766 KNetwork::KResolverResults res = KNetwork::KResolver::resolve(d->kssl->peerInfo().peerHost(),
"80", KNetwork::KResolver::CanonName);
767 if (!res.isEmpty()) {
768 TQString old = d->kssl->peerInfo().peerHost();
769 d->kssl->peerInfo().setPeerHost(res[0].canonicalName());
770 _IPmatchesCN = d->kssl->peerInfo().certMatchesAddress();
772 d->kssl->peerInfo().setPeerHost(old);
776 if (!_IPmatchesCN && !d->militantSSL) {
777 if (d->cc->getHostList(pc).contains(ourHost)) {
784 ksvl << KSSLCertificate::InvalidHost;
787 KSSLCertificate::KSSLValidation ksv = KSSLCertificate::Ok;
792 setMetaData(
"ssl_cipher", d->kssl->connectionInfo().getCipher());
794 d->kssl->connectionInfo().getCipherDescription());
796 d->kssl->connectionInfo().getCipherVersion());
798 TQString::number(d->kssl->connectionInfo().getCipherUsedBits()));
800 TQString::number(d->kssl->connectionInfo().getCipherBits()));
802 if (!d->realHost.isEmpty()) {
807 for(KSSLCertificate::KSSLValidationList::ConstIterator it = ksvl.begin();
808 it != ksvl.end(); ++it)
810 errorStr += TQString::number(*it)+
":";
813 setMetaData(
"ssl_peer_certificate", pc.toString());
815 if (pc.chain().isValid() && pc.chain().depth() > 1) {
817 TQPtrList<KSSLCertificate> chain = pc.chain().getChain();
818 chain.setAutoDelete(
true);
819 for (KSSLCertificate *c = chain.first(); c; c = chain.next()) {
820 theChain += c->toString();
826 setMetaData(
"ssl_cert_state", TQString::number(ksv));
828 if (ksv == KSSLCertificate::Ok) {
833 kdDebug(7029) <<
"SSL HTTP frame the parent? " <<
metaData(
"main_frame_request") << endl;
839 KSSLCertificateCache::KSSLCertificatePolicy cp =
840 d->cc->getPolicyByCertificate(pc);
843 if (ksv != KSSLCertificate::Ok) {
844 if (d->militantSSL) {
848 if (cp == KSSLCertificateCache::Unknown ||
849 cp == KSSLCertificateCache::Ambiguous) {
850 cp = KSSLCertificateCache::Prompt;
853 permacache = d->cc->isPermanent(pc);
865 case KSSLCertificateCache::Accept:
869 case KSSLCertificateCache::Reject:
873 case KSSLCertificateCache::Prompt:
876 if (ksv == KSSLCertificate::InvalidHost) {
877 TQString msg = i18n(
"The IP address of the host %1 "
878 "does not match the one the "
879 "certificate was issued to.");
882 i18n(
"Server Authentication"),
886 TQString msg = i18n(
"The server certificate failed the "
887 "authenticity test (%1).");
890 i18n(
"Server Authentication"),
895 if (result == KMessageBox::Yes) {
897 d->dcc =
new DCOPClient;
899 if (!d->dcc->isApplicationRegistered(
"tdeio_uiserver")) {
900 TDEApplication::startServiceByDesktopPath(
"tdeio_uiserver.desktop",
905 TQByteArray
data, ignore;
906 TQCString ignoretype;
907 TQDataStream arg(
data, IO_WriteOnly);
908 arg << theurl << mOutgoingMetaData;
909 arg <<
metaData(
"window-id").toInt();
910 d->dcc->call(
"tdeio_uiserver",
"UIServer",
911 "showSSLInfoDialog(TQString,TDEIO::MetaData,int)",
912 data, ignoretype, ignore);
914 }
while (result == KMessageBox::Yes);
916 if (result == KMessageBox::No) {
919 cp = KSSLCertificateCache::Accept;
922 i18n(
"Would you like to accept this "
923 "certificate forever without "
925 i18n(
"Server Authentication"),
927 i18n(
"&Current Sessions Only"));
928 if (result == KMessageBox::Yes)
935 cp = KSSLCertificateCache::Prompt;
940 kdDebug(7029) <<
"TCPSlaveBase/SSL error in cert code."
941 <<
"Please report this to kfm-devel@kde.org."
949 d->cc->addCertificate(pc, cp, permacache);
950 if (doAddHost) d->cc->addHost(pc, ourHost);
953 KSSLCertificateCache::KSSLCertificatePolicy cp =
954 d->cc->getPolicyByCertificate(pc);
959 bool certAndIPTheSame = (d->ip ==
metaData(
"ssl_parent_ip") &&
960 pc.toString() ==
metaData(
"ssl_parent_cert"));
962 if (ksv == KSSLCertificate::Ok) {
963 if (certAndIPTheSame) {
988 if (d->militantSSL) {
992 if (cp == KSSLCertificateCache::Accept) {
993 if (certAndIPTheSame) {
998 i18n(
"You have indicated that you wish to accept this certificate, but it is not issued to the server who is presenting it. Do you wish to continue loading?"),
999 i18n(
"Server Authentication"));
1000 if (result == KMessageBox::Yes) {
1003 d->cc->addHost(pc, ourHost);
1009 }
else if (cp == KSSLCertificateCache::Reject) {
1010 messageBox(Information, i18n(
"SSL certificate is being rejected as requested. You can disable this in the Trinity Control Center."),
1011 i18n(
"Server Authentication"));
1016 TQString msg = i18n(
"The server certificate failed the "
1017 "authenticity test (%1).");
1020 i18n(
"Server Authentication"),
1023 if (result == KMessageBox::Yes) {
1025 d->dcc =
new DCOPClient;
1027 if (!d->dcc->isApplicationRegistered(
"tdeio_uiserver")) {
1028 TDEApplication::startServiceByDesktopPath(
"tdeio_uiserver.desktop",
1032 TQByteArray
data, ignore;
1033 TQCString ignoretype;
1034 TQDataStream arg(
data, IO_WriteOnly);
1035 arg << theurl << mOutgoingMetaData;
1036 arg <<
metaData(
"window-id").toInt();
1037 d->dcc->call(
"tdeio_uiserver",
"UIServer",
1038 "showSSLInfoDialog(TQString,TDEIO::MetaData,int)",
1039 data, ignoretype, ignore);
1041 }
while (result == KMessageBox::Yes);
1043 if (result == KMessageBox::No) {
1046 cp = KSSLCertificateCache::Accept;
1048 i18n(
"Would you like to accept this "
1049 "certificate forever without "
1051 i18n(
"Server Authentication"),
1053 i18n(
"&Current Sessions Only"));
1054 permacache = (result == KMessageBox::Yes);
1055 d->cc->addCertificate(pc, cp, permacache);
1056 d->cc->addHost(pc, ourHost);
1060 cp = KSSLCertificateCache::Prompt;
1061 d->cc->addCertificate(pc, cp, permacache);
1072 if (
metaData(
"ssl_activate_warnings") ==
"TRUE") {
1074 if (!isChild &&
metaData(
"ssl_was_in_use") ==
"FALSE" &&
1075 d->kssl->settings()->warnOnEnter()) {
1078 result =
messageBox( i18n(
"You are about to "
1079 "enter secure mode. "
1080 "All transmissions "
1081 "will be encrypted "
1083 "noted.\nThis means "
1084 "that no third party "
1086 "easily observe your "
1087 "data in transit."),
1089 i18n(
"Security Information"),
1093 "WarnOnEnterSSLMode" );
1095 TDEConfig *
config =
new TDEConfig(
"tdeioslaverc");
1096 config->setGroup(
"Notification Messages");
1098 bool dialogBoxStatus =
false;
1099 if(
config->hasKey(
"WarnOnEnterSSLMode") ) {
1100 dialogBoxStatus =
true;
1102 bool keyStatus =
config->readBoolEntry(
"WarnOnEnterSSLMode",
true);
1103 dialogBoxStatus = dialogBoxStatus && keyStatus;
1105 config->deleteEntry(
"WarnOnEnterSSLMode");
1107 d->kssl->settings()->setWarnOnEnter(
false);
1108 d->kssl->settings()->save();
1112 if ( result == KMessageBox::Yes )
1115 d->dcc =
new DCOPClient;
1117 if (!d->dcc->isApplicationRegistered(
"tdeio_uiserver")) {
1118 TDEApplication::startServiceByDesktopPath(
"tdeio_uiserver.desktop",
1122 TQByteArray
data, ignore;
1123 TQCString ignoretype;
1124 TQDataStream arg(
data, IO_WriteOnly);
1125 arg << theurl << mOutgoingMetaData;
1126 arg <<
metaData(
"window-id").toInt();
1127 d->dcc->call(
"tdeio_uiserver",
"UIServer",
1128 "showSSLInfoDialog(TQString,TDEIO::MetaData,int)",
1129 data, ignoretype, ignore);
1132 if(dialogBoxStatus) {
1135 }
while (result != KMessageBox::No);
1141 kdDebug(7029) <<
"SSL connection information follows:" << endl
1142 <<
"+-----------------------------------------------" << endl
1143 <<
"| Cipher: " << d->kssl->connectionInfo().getCipher() << endl
1144 <<
"| Description: " << d->kssl->connectionInfo().getCipherDescription() << endl
1145 <<
"| Version: " << d->kssl->connectionInfo().getCipherVersion() << endl
1146 <<
"| Strength: " << d->kssl->connectionInfo().getCipherUsedBits()
1147 <<
" of " << d->kssl->connectionInfo().getCipherBits()
1148 <<
" bits used." << endl
1149 <<
"| PEER:" << endl
1150 <<
"| Subject: " << d->kssl->peerInfo().getPeerCertificate().getSubject() << endl
1151 <<
"| Issuer: " << d->kssl->peerInfo().getPeerCertificate().getIssuer() << endl
1152 <<
"| Validation: " << (int)ksv << endl
1153 <<
"| Certificate matches IP: " << _IPmatchesCN << endl
1154 <<
"+-----------------------------------------------"
1164 if ( m_iSock == -1 )
1169 FD_SET(m_iSock , &rdfs);
1177 retval = KSocks::self()->select(m_iSock+1, &rdfs, NULL, NULL, &tv);
1180 }
while ((retval == -1) && (errno == EAGAIN));
1200 retval = KSocks::self()->recv(m_iSock, buffer, 80, MSG_PEEK);
1202 }
while ((retval == -1) && (errno == EAGAIN));
1218 struct timeval timeout;
1220 if ( (m_bIsSSL || d->usingTLS) && !d->useSSLTunneling && d->kssl )
1221 if (d->kssl->pending() > 0)
1225 FD_SET(m_iSock, &rd);
1227 timeout.tv_usec = 0;
1235 startTime = time(NULL);
1237 rc = KSocks::self()->select(m_iSock+1, &rd, NULL, NULL, &timeout);
1247 if (FD_ISSET(m_iSock, &rd))
1253 int timeDone = time(NULL) - startTime;
1281 return d->useSSLTunneling;
1286 d->useSSLTunneling = enable;
1291 d->realHost = realHost;
1294 bool TCPSlaveBase::doSSLHandShake(
bool sendError )
1296 kdDebug(7029) <<
"TCPSlaveBase::doSSLHandShake: " << endl;
1297 TQString msgHost = d->host;
1299 d->kssl->reInitialize();
1302 KSSLSession *s = KSSLSession::fromString(
metaData(
"ssl_session_id"));
1304 d->kssl->takeSession(s);
1308 certificatePrompt();
1310 if ( !d->realHost.isEmpty() )
1312 msgHost = d->realHost;
1315 kdDebug(7029) <<
"Setting real hostname: " << msgHost << endl;
1316 d->kssl->setPeerHost(msgHost);
1318 d->status = d->kssl->connect(m_iSock);
1323 error( ERR_COULD_NOT_CONNECT, msgHost);
1327 setMetaData(
"ssl_session_id", d->kssl->session()->toString());
1330 if (!d->kssl->reusingSession()) {
1331 int rc = verifyCertificate();
1336 error( ERR_COULD_NOT_CONNECT, msgHost);
1341 d->needSSLHandShake =
false;
1343 d->savedMetaData = mOutgoingMetaData;
1348 bool TCPSlaveBase::userAborted()
const
1350 return d->userAborted;
1353 void TCPSlaveBase::virtual_hook(
int id,
void* data )
1354 { SlaveBase::virtual_hook(
id,
data ); }
static int connectTimeout()
Returns the preferred timeout value for remote connections in seconds.
This class is intended to make it easier to prompt for, cache and retrieve authorization information.
TQString username
This is required for caching.
TQString prompt
Information to be displayed when prompting the user for authentication information.
KURL url
The URL for which authentication is to be stored.
TQString password
This is required for caching.
bool keepPassword
Flag to indicate the persistence of the given password.
TQString caption
The text to displayed in the title bar of the password prompting dialog.
There are two classes that specifies the protocol between application (job) and tdeioslave.
bool wasKilled() const
If your ioslave was killed by a signal, wasKilled() returns true.
bool openPassDlg(TDEIO::AuthInfo &info, const TQString &errorMsg)
Prompt the user for Authorization info (login & password).
TDEConfigBase * config()
Returns a configuration object to query config/meta-data information from.
void data(const TQByteArray &data)
Sends data in the slave to the job (i.e.
int messageBox(MessageBoxType type, const TQString &text, const TQString &caption=TQString::null, const TQString &buttonYes=TQString::null, const TQString &buttonNo=TQString::null)
Call this to show a message box from the slave.
void setMetaData(const TQString &key, const TQString &value)
Sets meta-data to be send to the application before the first data() or finished() signal.
bool hasMetaData(const TQString &key) const
Queries for the existence of a certain config/meta-data entry send by the application to the slave.
TQString metaData(const TQString &key) const
Queries for config/meta-data send by the application to the slave.
void error(int _errid, const TQString &_text)
Call to signal an error.
bool checkCachedAuthentication(AuthInfo &info)
Checks for cached authentication based on parameters given by info.
bool atEnd()
Returns true when end of data is reached.
bool usingTLS() const
Are we using TLS?
void setEnableSSLTunnel(bool enable)
Set up SSL tunneling mode.
bool initializeSSL()
Initializs all SSL variables.
void setConnectTimeout(int t)
Sets how long to wait for orignally connecting to the requested before timinig out.
void cleanSSL()
Cleans up all SSL settings.
void setBlockSize(int sz)
Sets the maximum size of blocks read in during calls to readLine().
void setRealHost(const TQString &realHost)
Sets up the the real hostname for an SSL connection that goes through a proxy server.
ssize_t write(const void *data, ssize_t len)
This function acts like standard write function call except it is also capable of making SSL or SOCKS...
bool connectToHost(const TQString &host, unsigned int port, bool sendError=true)
Performs the initial TCP connection stuff and/or SSL handshaking as necessary.
int connectResult()
Returns the status of the connection.
bool isConnectionValid()
Determines whether or not we are still connected to the remote machine.
void setBlockConnection(bool b)
Sets the mode of the connection to blocking or non-blocking.
bool canUseTLS()
Can we use TLS?
void closeDescriptor()
Closes the current file descriptor.
void setSSLMetaData()
Call this if you use persistent connections and want all the metadata restored.
bool waitForResponse(int t)
Wait for some type of activity on the socket for the period specified by t.
ssize_t readLine(char *data, ssize_t len)
Same as above except it reads data one line at a time.
bool isSSLTunnelEnabled()
Returns true if SSL tunneling is enabled.
void stopTLS()
Stop using TLS on the connection.
int startTLS()
Start using TLS on the connection.
ssize_t read(void *data, ssize_t len)
This function acts like standard read function call except it is also capable of deciphering SSL data...
unsigned short int port(unsigned short int _port)
Determines the appropriate port to use.
A namespace for TDEIO globals.