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

handle TLS SNI #1101

Merged
merged 1 commit into from
Mar 24, 2015
Merged

handle TLS SNI #1101

merged 1 commit into from
Mar 24, 2015

Conversation

nyov
Copy link
Contributor

@nyov nyov commented Mar 24, 2015

implement the SNI fix as given in #981

nyov added a commit to nyov/scrapy that referenced this pull request Mar 24, 2015
nyov added a commit to nyov/scrapy that referenced this pull request Mar 24, 2015
@nyov
Copy link
Contributor Author

nyov commented Mar 24, 2015

I noticed ClientTLSOptions works only with twisted 14.0 or later.
Earlier versions might be hackable using OpenSSLCertificateOptions instead, which was available then. But I couldn't try so I just stick with the old behavior then.

@@ -17,4 +23,6 @@ def getContext(self, hostname=None, port=None):
# Enable all workarounds to SSL bugs as documented by
# http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html
ctx.set_options(SSL.OP_ALL)
if hostname and ClientTLSOptions is not None: # workaround for TLS SNI
ClientTLSOptions(hostname, ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure but I think this should be applied only to TLS connections. It would be good to test it against different versions of SSL and TLS protocols to make sure it works as expected in all the cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the docstring and the import line, I just figured this was only applicable to SSL connections anyway.
We're also only accepting TLSv1 connections here (self.method = SSL.TLSv1_METHOD).
(Anything else is just stupid now anyway, after SSL3 has mostly left the building).
So there isn't much need to test other protocols for this class ( unless someone overrides the TLS line here, then that'd be an unsupported case ).

That's not to say that a test-case wouldn't be great.
But I noticed that all my SNI sites also work without that fix (strange), so I have no real host to point a testcase at, and it should preferrably be an offline test anyway? If such a test can even be fabricated.
Any help welcome.

Copy link
Member

Choose a reason for hiding this comment

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

I'd merge this and put in the wild under unstable branch so we can get more feedback.

@dangra
Copy link
Member

dangra commented Mar 24, 2015

LGTM.

dangra added a commit that referenced this pull request Mar 24, 2015
@dangra dangra merged commit ad36de4 into scrapy:master Mar 24, 2015
@nyov nyov deleted the nyov/tls-sni branch March 27, 2015 04:57
sibiryakov pushed a commit to sibiryakov/scrapy that referenced this pull request Apr 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants