Skip to content
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

Backport of ccae4a1582efcad311d095a8e6832b2b67d5ed05 #918

Conversation

indutny
Copy link
Contributor

@indutny indutny commented Mar 28, 2016

This is a backport of two commits:

Main differences between ccae4a1 and approach here:

1.0.2 has two clients: s23 and s3. s->method was set early on SSL_set_session call to make SSL_connect call s3_client_hello, which is capable of generating client hello with session. So the logical step was to introduce session field to s23_client_hello. Additionally, some copy-pasted code was added in s3_clnt to handle session resumption and version support.

NULL and deprecate ssl_get_method instead of removing it from the structure. Needed for ABI-compatbility.

ssl23_version_supported is slightly different, as there are no method tables in 1.0.2. Hopefully it is ok.

Notes

I took some courage to include some other changes from master into ssltest to allow running tests from b7dffce. However dtls tests are in quite odd shape here, since there are no -dtls flag (will probably add it later, if the rest looks ok).

cc @kroeckx @mattcaswell @davidben PTAL, I will be glad to answer any questions or incorporate any suggested changes. Tests appears to be passing locally.

return DTLSv1_2_client_method();
else
return NULL;
}
Copy link
Member

Choose a reason for hiding this comment

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

So it looks like those function also become unused in 1.0.2, but maybe we should keep them around and try to minimize the changes. I'm not sure yet what I want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, just for the sake of compatibility. I agree.

@kroeckx
Copy link
Member

kroeckx commented Mar 28, 2016

You should probably also backport @davidben's dtls commit 1ed6587, which is related to this anyway. The dtls tests didn't pass in master without that change.

We now send the highest supported version by the client, even if the session
uses an older version.

This fixes 2 problems:
- When you try to reuse a session but the other side doesn't reuse it and
uses a different protocol version the connection will fail.
- When you're trying to reuse a session with an old version you might be
stuck trying to reuse the old version while both sides support a newer
version
if (s->new_session || s->session == NULL)
i = 0;
else
i = s->session->session_id_length;
Copy link
Member

Choose a reason for hiding this comment

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

I see this in various places, but I have to wonder that new_session is correct or not, both here and in the master branch. At least the ssl_get_new_session() call doesn't seem to set that, nor does SSL_set_session().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check it, but this code is really a copy-paste from s3_clnt.c.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like s->new_session here handles the case of handshake right after SSL_renegotiate().

davidben and others added 2 commits March 28, 2016 12:18
Session resumption involves a version check, so version negotiation must
happen first. Currently, the DTLS implementation cannot do session
resumption in DTLS 1.0 because the ssl_version check always checks
against 1.2.

Switching the order also removes the need to fixup ssl_version in DTLS
version negotiation.
@indutny indutny force-pushed the feature/backport-ccae4a1582efcad311d095a8e6832b2b67d5ed05 branch from d5b927c to 5e4d5ac Compare March 28, 2016 16:18
@indutny
Copy link
Contributor Author

indutny commented Mar 28, 2016

@kroeckx pushed new commits. Looking into new_session.

The concern that I have so far, is that DTLS_ANY_VERSION seems to be working differently for clients in 1.0.2. It looks like it selects either DTLSv1 or DTLSv1_2 during generation of ClientHello. So there is no chance to make tests work as they do in master. Hopefully, my backport attempt will cover some of the cases.

Additional concern is that those tests are passing without @davidben 's DTLS-cookie commit. It doesn't break stuff either, so I committed it anyway.

@indutny
Copy link
Contributor Author

indutny commented Mar 29, 2016

@kroeckx kindly reminding you about this.

@indutny
Copy link
Contributor Author

indutny commented Apr 4, 2016

@kroeckx kindly reminder, sorry if this is too noisy!

@kroeckx
Copy link
Member

kroeckx commented Apr 4, 2016

I was just going to look at this again ...

*/
int ssl23_version_supported(const SSL *s, int version)
{
if (s->method == SSLv23_method()) {
Copy link
Member

Choose a reason for hiding this comment

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

This at least looks wrong. It can be a SSLv23_client_method() too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh gosh, you are right. Fixed. (Added server_method too, just for consistency).

@kroeckx
Copy link
Member

kroeckx commented Apr 4, 2016

So it looks like your changes in s3_srvr.c actually is the DTLS fix.

@indutny
Copy link
Contributor Author

indutny commented Apr 4, 2016

I was just going to look at this again ...

Yikes, sorry for pinging you then. I won't bother you with these "pings" anymore, sorry!

So it looks like your changes in s3_srvr.c actually is the DTLS fix.

They are indeed!

@MylesBorins
Copy link

MylesBorins commented Apr 30, 2016

@kroeckx what's the status on this?

@indutny
Copy link
Contributor Author

indutny commented May 11, 2016

@kroeckx I'm really sorry to bother you, but may I ask you to take a look at this? It seems that activity has ceased on this thread 😢

cc @richsalz @mattcaswell

} else if (strcmp(*argv, "-should_negotiate") == 0) {
if (--argc < 1)
goto bad;
should_negotiate = *(++argv);
Copy link
Member

Choose a reason for hiding this comment

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

This is adding new features to a stable branch which we cannot do.

Copy link
Contributor

Choose a reason for hiding this comment

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

You mean only that one part, right? Not the rest of this which seems like a bugfix (correct me if I'm wrong). And then, does adding this could make it possible to test the bugfix?

Copy link
Member

Choose a reason for hiding this comment

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

Yes - just this bit. I understand that the test uses this - but I still don't thing we should add this bit to a stable branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this just a test binary that isn't shipped anywhere? It's not adding a flag to the openssl binary, as far as I can tell.

Copy link
Member

Choose a reason for hiding this comment

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

Ahhh....oh, yes my mistake. I thought I was looking at an "apps" file here. I withdraw my comment.

@mattcaswell mattcaswell added this to the 1.0.2 milestone May 16, 2016
@kroeckx kroeckx self-assigned this May 17, 2016
@MylesBorins
Copy link

Hey all... wanted to quickly ping to see what the status of this is. @indutny looks like you may need to rebase

@indutny
Copy link
Contributor Author

indutny commented Jun 24, 2016

Kindly reminding you about this.

@richsalz
Copy link
Contributor

+1. Ship it, @kroeckx :)

@mattcaswell
Copy link
Member

Ping @kroeckx

@richsalz
Copy link
Contributor

@kroeckx ... still worth doing this?

@richsalz richsalz added branch: 1.0.2 Merge to OpenSSL_1_0_2-stable branch approval: done This pull request has the required number of approvals labels Jun 16, 2017
@kroeckx
Copy link
Member

kroeckx commented Jun 17, 2017 via email

@richsalz
Copy link
Contributor

This looks okay to me but I would be happier if @mattcaswell would also take a look.

@mattcaswell
Copy link
Member

This change makes me nervous. I'm thinking this is too big to backport.

@mattcaswell
Copy link
Member

No further discussion on this, so I'm closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals branch: 1.0.2 Merge to OpenSSL_1_0_2-stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants