-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC-32715 SSL_connect/accept should honor timeout provided #19156
base: candidate-9.8.x
Are you sure you want to change the base?
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-32715 Jirabot Action Result: |
Signed-off-by: M Kelly <[email protected]>
1167a59
to
b1150b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mckellyln - please see comments.
m_socket = ISocket::connect_timeout(ep, m_connectTimeoutMs); | ||
|
||
if(strcmp(m_protocol.get(), "HTTPS") == 0) | ||
{ | ||
ISecureSocket* securesocket = m_ssctx->createSecureSocket(m_socket, SSLogNormal, m_host.str()); | ||
int res = securesocket->secure_connect(); | ||
unsigned remainingMs = timer.remainingMs(m_connectTimeoutMs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remainingMs could be zero here (due to some weird delay in createSecureSocket),
but strictly speaking it should probably abort if so before trying to call secure_connect.
while (true) | ||
{ | ||
err = SSL_accept(m_ssl); | ||
if (err > 0) | ||
{ | ||
if (logLevel > SSLogNormal) | ||
if (this->m_loglevel > SSLogNormal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "this->"? (and other lines)
[ no other member variable is qualified this way ]
@@ -16,6 +16,7 @@ | |||
############################################################################## */ | |||
|
|||
// Some ssl prototypes use char* where they should be using const char *, resulting in lots of spurious warnings | |||
#include "jexcept.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the #include "jliball.hpp" already includes jexecpt.hpp (on line 25)
(jliball seems like a bad idea - but not new)
@@ -2304,7 +2313,7 @@ class CSingletonSecureSocketConnection: public CSingletonSocketConnection | |||
if (srtn) | |||
{ | |||
Owned<ISecureSocket> ssock = secureContextServer->createSecureSocket(sock.getClear(), tlsLogLevel); | |||
int status = ssock->secure_accept(tlsLogLevel); | |||
int status = ssock->secure_accept(timeoutms); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this (CSingletonSecureSocketConnection::accept) method should also have a CCycleTimer added before the line 2312, and pass timer.remainingMs to secure_accept here.
@@ -44,6 +44,8 @@ | |||
#define WAIT_FOREVER ((unsigned)-1) | |||
#endif | |||
|
|||
#define DEFAULT_CONNECT_TIME (100*1000) // for connect_wait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now used for accept too, prob. either worth updating the comment, or introducing another #define (or constexpr) for defaultAcceptTimeMs.
@@ -1343,7 +1354,7 @@ unsigned getRemoteVersion(ISocket *origSock, StringBuffer &ver) | |||
if (!origSock) | |||
return 0; | |||
|
|||
Owned<ISocket> socket = checkSocketSecure(origSock); | |||
Owned<ISocket> socket = checkSocketSecure(origSock, 10000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any significance to 10000 vs using default ?
@@ -63,7 +63,7 @@ extern DAFSCLIENT_API int getDafsInfo(ISocket * socket, unsigned level, StringBu | |||
extern DAFSCLIENT_API void setDafsEndpointPort(SocketEndpoint &ep); | |||
extern DAFSCLIENT_API void setDafsLocalMountRedirect(const IpAddress &ip,const char *dir,const char *mountdir); | |||
extern DAFSCLIENT_API ISocket *connectDafs(SocketEndpoint &ep, unsigned timeoutms, const IPropertyTree *service); // NOTE: might alter ep.port if configured for multiple ports ... | |||
extern DAFSCLIENT_API ISocket *checkSocketSecure(ISocket *socket); | |||
extern DAFSCLIENT_API ISocket *checkSocketSecure(ISocket *socket, unsigned timeoutms); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpp has unsigned timeoutms = DEFAULT_CONNECT_TIME, I suspect default should be here.
@@ -142,7 +142,7 @@ class CascadeManager : public CInterface | |||
if (!ssock) | |||
throw makeStringException(ROXIE_TLS_ERROR, "Roxie CascadeManager failed creating secure socket for roxie control message"); | |||
|
|||
int status = ssock->secure_connect(); | |||
int status = ssock->secure_connect(2000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do wonder whether the secure socket connect/accept defaults should be different from the jsocket defaults.
These timings (to ssl connect/accept) would generally expect to be shorter than connecting to the raw socket.
And then maybe this/other places, could generally rely on the defaults.
int tlsTraceLevel = SSLogMin; | ||
if (parent->mpTraceLevel >= MPVerboseMsgThreshold) | ||
tlsTraceLevel = SSLogMax; | ||
int status = ssock->secure_connect(tlsTraceLevel); | ||
Owned<ISecureSocket> ssock = secureContextClient->createSecureSocket(newsock.getClear(), tlsTraceLevel); | ||
tm.timedout(&remaining); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think should be:
if (tm.timedout(&remaining))
return false;
int tlsTraceLevel = SSLogMin; | ||
if (parent->mpTraceLevel >= MPVerboseMsgThreshold) | ||
tlsTraceLevel = SSLogMax; | ||
int status = ssock->secure_accept(tlsTraceLevel); | ||
Owned<ISecureSocket> ssock = secureContextServer->createSecureSocket(sock.getClear(), tlsTraceLevel); | ||
int status = ssock->secure_accept(10000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see other comment(s). There's a few different constants used for secure_connect/secure_accept, in most cases sensible defaults should be used. I think secure socket connect/accept should have different defaults to jsocket's raw socket connect/accept. They are not expected to have the same timing semantics.
@mckellyln - I think this is a significant enough change that it should target master. |
Type of change:
Checklist:
Smoketest:
Testing: