[Twisted-Python] 'module' object has no attribute 'optionsForClientTLS'

I am trying to execute the check_server_certificate.py and I am getting this error… can you guys help me figure out whats going on? its the exact sample code on the website running on Ubuntu 14.04. Here is the error output: Traceback (most recent call last): File "check_server_certificate.py", line 28, in <module> task.react(main, sys.argv[1:]) File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 867, in react finished = main(_reactor, *argv) File "check_server_certificate.py", line 6, in main options = ssl.optionsForClientTLS(hostname=host.decode('utf-8')) AttributeError: 'module' object has no attribute 'optionsForClientTLS' Here is the code (check_server_certificate.py): from __future__ import print_function import sys from twisted.internet import defer, endpoints, protocol, ssl, task, error def main(reactor, host, port=443): options = ssl.optionsForClientTLS(hostname=host.decode('utf-8')) port = int(port) class ShowCertificate(protocol.Protocol): def connectionMade(self): self.transport.write(b"GET / HTTP/1.0\r\n\r\n") self.done = defer.Deferred() def dataReceived(self, data): certificate = ssl.Certificate(self.transport.getPeerCertificate()) print("OK:", certificate) self.transport.abortConnection() def connectionLost(self, reason): print("Lost.") if not reason.check(error.ConnectionClosed): print("BAD:", reason.value) self.done.callback(None) return endpoints.connectProtocol( endpoints.SSL4ClientEndpoint(reactor, host, port, options), ShowCertificate() ).addCallback(lambda protocol: protocol.done) task.react(main, sys.argv[1:]) Rudy Aramayo | Developer | OrbitusRobotics LLC Direct: 626.386.8329 | Email: orbitus@orbitusrobotics.com | Web: www.orbitusrobotics.com "This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this email in error please notify me (orbitus@orbitusrobotics.com). If you are not the named addressee you should not disseminate, distribute or copy this e-mail and should delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.”

I am trying to execute the check_server_certificate.py and I am getting this error… can you guys help me figure out whats going on? its the exact sample code on the website running on Ubuntu 14.04.
Trusty is shipping Twisted 13.2 which doesn't have vital TLS improvements that arrived with 14.0 and that are used in said example. I strongly recommend against using Twisted older than 14.0 for code involving TLS. Please use the version from PyPI (14.0.2).

I am trying to execute the check_server_certificate.py and I am getting this error… can you guys help me figure out whats going on? its the exact sample code on the website running on Ubuntu 14.04.
Trusty is shipping Twisted 13.2 which doesn't have vital TLS improvements that arrived with 14.0 and that are used in said example. I strongly recommend against using Twisted older than 14.0 for code involving TLS. Please use the version from PyPI (14.0.2).
participants (2)
-
Hynek Schlawack
-
Orbitus