<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 26, 2017, at 10:32 AM, Paul Tremberth <<a href="mailto:paul.tremberth@gmail.com" class="">paul.tremberth@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello,<br class=""><br class="">The other day, we had a Scrapy user report an issue connecting to <a href="https://www.skelbiu.lt/" class="">https://www.skelbiu.lt/</a> with OpenSSL 1.1 [1]<br class=""></div></div></blockquote><div><br class=""></div><div>Thanks for passing this issue on!  Always nice to have users engaging directly with us rather than trying janky workarounds :).</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">To not mix scrapy's things with Twisted Web, I used this (adapted from official docs):<br class=""></div></div></blockquote><div><br class=""></div>That's a good example to use, yes.<br class=""><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">And I did get a Handshake failure too:<br class=""><br class="">    $ python twistedtest.py <br class="">    [Failure instance: Traceback (failure with no frames): <class 'twisted.web._newclient.ResponseNeverReceived'>: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('SSL routines', 'ssl3_read_bytes', 'sslv3 alert handshake failure')]>]<br class="">    ]<br class=""><br class="">It seems this happens (at least) with OpenSSL 1.1.0e (currently in Debian 9 sid [2])<br class="">It does not happen (for me) with OpenSSL 1.0.2g for example.<br class=""></div></div></blockquote><div><br class=""></div><div>What platform are you on?  How do you know what version of OpenSSL you're using?  (It can sometimes be quite tricky to suss out what OpenSSL twisted is using unless you know the internals fairly well, unfortunately; 'twist --version' really ought to print it out.)</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">I dug into this this afternoon and narrowed it down to the use of <div class="">_defaultCurveName = u"prime256v1"</div><div class="">in twisted.internet._sslverify.py<br class=""><br class=""></div><div class="">I tried patching the current trunk with _defaultCurveName = u"secp384r1" (the EC that <a href="http://ssllabs.com/" class="">ssllabs.com</a> reports)<br class="">and it did work.<br class=""><br class="">Looking at ClientHello messages for openssl 1.0.2 and 1.1 [4]:<br class="">with 1.1, only 1 Elliptic Curve is sent by Twisted Web Agent, secp256r1<br class=""></div></div></div></blockquote><div><br class=""></div><div>What about with 1.0.2?</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">openssl v1.1 client uses 4 by default: ecdh_x25519, secp256r1, secp521r1, secp384r1<br class=""><br class="">I was wondering what is the proper way to configure requested Elliptic Curves.<br class="">I haven't seen any interface for this, contrary to ciphers with acceptableCiphers.<br class=""></div></div></div></blockquote><div><br class=""></div><div>It's possible that there should be an interface for this, but, <i class="">your</i> issue should not be fixed with an API to work around this bug.  It should be fixed with a <i class="">fix</i> for this bug.</div><div><br class=""></div><div>My understanding is that Twisted just configures one curve, whereas OpenSSL configures 4.</div><div><br class=""></div><div>Twisted should just configure all 4 (unless there's some security reason not to match OpenSSL's behavior, which we should probably check on).</div><div><br class=""></div><div>Just guessing based on what I see here, I imagine that would mean getting rid of the _ecCurve attribute, and instead having an _ecCurves = something; then, getting rid of the call to SSL_CTX_set_tmp_ecdh and instead using SSL_CTX_set1_curves, as <a href="https://github.com/openssl/openssl/commit/6977e8ee4a718a76351ba5275a9f0be4e530eab5" class="">https://github.com/openssl/openssl/commit/6977e8ee4a718a76351ba5275a9f0be4e530eab5</a> seems to indicate that's how you have to request multiple curves at once.</div><div><br class=""></div><div>Twisted should just fix this, not make it configurable.  Later, for security testing purposes, we may want to make it a fine-grained configurable thing, but for right now the priority should be getting correct behavior into a release.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">Thank you for your input.</div></div></div></blockquote><br class=""></div><div>Thanks for using Twisted!</div></body></html>