Skip to content

Add vconn reenable event#4427

Merged
shinrich merged 1 commit intoapache:masterfrom
shinrich:add-vconn-reenable-event
Oct 29, 2018
Merged

Add vconn reenable event#4427
shinrich merged 1 commit intoapache:masterfrom
shinrich:add-vconn-reenable-event

Conversation

@shinrich
Copy link
Copy Markdown
Member

Depends on PR #4414. So this PR is only the second commit. Most of the changes are in the first commit (PR #4414).

Adds TSVConnReenableEx(), which is like TSVConnReenable() but it takes a TSEvent argument as the Txn and Ssn reenable functions do. With the event argument the plugin can indicate back to the core whether the plugin fails and the underlying VConn should error out.

This PR adds a test to exercise the TS_SSL_SERVER_VERIFY_HOOK with a plugin. The plugin fails some of the handshakes based on detecting a "bad" cert.

As an API change, I will send an API review email on the dev mailing list.


An extended verion of TSVConnEnable that allows the plugin to return a status to
the core logic. If all goes well this is TS_EVENT_VCONN_CONTINUE. However, if
the plugin wants to stop the processing it can set the event to TS_EVENT_VCONN_CONTINUE.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean TS_EVENT_VCONN_ERROR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will fix.

Comment thread include/ts/apidefs.h.in Outdated
TS_EVENT_SSL_VERIFY_CLIENT = 60206
TS_EVENT_SSL_VERIFY_CLIENT = 60206,
TS_EVENT_VCONN_CONTINUE = 60207,
TS_EVENT_VCONN_ERROR = 60208
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't TS_EVENT_CONTINUE and TS_EVENT_ERROR (generic) be used? Or, why do we need an event at all, why not:

tsapi void TSVConnErrorTermination(TSVConn sslvcp);

instead of:

tsapi void TSVConnReenableEx(TSVConn sslvcp, TSEvent event);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. There is a already a TS_EVENT_ERROR/CONTINUE. I was following the pattern of TSHttpTxnReenable/TSHttpSsnReenable with TS_EVENT_HTTP_ERROR/CONTINUE.

We could use TS_EVENT_ERROR/CONTINUE instead of adding another pair of events.

I do like the Reenable pattern with a general event argument rather than having an explicit error reenable method. This gives you the option of inserting different events to impact processing in the future.

if (netvc && netvc->options.verifyServerPolicy == YamlSNIConfig::Policy::DISABLED) {
return true; // Tell them that all is well
} else if (!netvc) { // No netvc, very bad. Go away. Things are not good.
return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need an entry in diags.log, or even ink_assert in this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. This is in the other commit. Will update in the other PR.

Comment thread iocore/net/SSLClientUtils.cc Outdated
cert = X509_STORE_CTX_get_current_cert(ctx);
err = X509_STORE_CTX_get_error(ctx);

bool enforce_mode = (netvc && netvc->options.verifyServerPolicy == YamlSNIConfig::Policy::ENFORCED);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After line 59 no more checks of netvc being non-null are needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Will fix in other PR

Comment thread iocore/net/SSLConfig.cc Outdated
Warning("%s is invalid for proxy.config.ssl.client.verify.server.policy. Should be one of DISABLED, PERMISSIVE, or ENFORCED",
verify_server);
verifyServerPolicy = YamlSNIConfig::Policy::DISABLED;
;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emoji? @SolidWallOfCode may get jealous wondering who you're winking at.

Comment thread iocore/net/SSLConfig.cc Outdated
verifyServerProperties = YamlSNIConfig::Property::ALL_MASK;
} else if (strcmp(verify_server, "NONE") == 0) {
verifyServerProperties = YamlSNIConfig::Property::NONE;
;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More cause for jealously?

Comment thread iocore/net/SSLNetVConnection.cc Outdated
if (!this->getSSLHandShakeComplete()) {
this->sslHandShakeComplete = true;
this->sslHandshakeStatus = SSL_HANDSHAKE_DONE;
;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++emoji

Comment thread iocore/net/SSLConfig.cc
ats_free(verify_server);

REC_ReadConfigStringAlloc(verify_server, "proxy.config.ssl.client.verify.server.properties");
if (strcmp(verify_server, "SIGNATURE") == 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be strcasecmp()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the keyword is upcase

Comment thread iocore/net/YamlSNIConfig.h Outdated
constexpr char TS_verify_origin_server[] = "verify_origin_server";
constexpr char TS_client_cert[] = "client_cert";
constexpr char TS_ip_allow[] = "ip_allow";
constexpr char TS_fqdn[] = "fqdn";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#define X(ID) constexpr char TS_##ID #ID; 
X(fqdn)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see. A means to avoid double typing (and messing up) the same string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a thought, I suppose some might find it overly tricky. To me, this sort of technique makes it more clear when there's a consistent pattern. Also helps avoid typos.

Comment thread iocore/net/YamlSNIConfig.h Outdated
constexpr char TS_verify_server_properties[] = "verify_server_properties";
constexpr char TS_verify_origin_server[] = "verify_origin_server";
constexpr char TS_client_cert[] = "client_cert";
constexpr char TS_ip_allow[] = "ip_allow";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#undef X

@shinrich shinrich force-pushed the add-vconn-reenable-event branch 2 times, most recently from ec9c52c to 949e83a Compare October 18, 2018 14:45
@shinrich
Copy link
Copy Markdown
Member Author

Addressed the remainder of @ywkaras's comments on PR #4414

@shinrich shinrich closed this Oct 18, 2018
@shinrich
Copy link
Copy Markdown
Member Author

Accidentally closed.

@shinrich
Copy link
Copy Markdown
Member Author

Updated the PR to rebase against the pre-cursor PR which has been merged in.

@shinrich shinrich force-pushed the add-vconn-reenable-event branch from 25119ea to 64359be Compare October 24, 2018 20:01
@shinrich
Copy link
Copy Markdown
Member Author

updated to actually add the test files to the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants