GithubHelp home page GithubHelp logo

tlsfuzzer / tlslite-ng Goto Github PK

View Code? Open in Web Editor NEW
227.0 227.0 79.0 4.06 MB

TLS implementation in pure python, focused on interoperability testing

License: Other

Makefile 0.18% Python 99.81% Shell 0.01% HTML 0.01%
ecdsa https https-client rsa security-protocol ssl tls tls12 tls13

tlslite-ng's Introduction

Build Status Read the Docs Coverage Status Code Climate

tlsfuzzer

tlsfuzzer is a test suite for SSLv2, SSLv3, TLS 1.0, TLS 1.1, TLS 1.2, and TLS 1.3 implementations. It's in early stages of development, so there are no API stability guarantees. While it uses fuzzing techniques for testing (randomisation of passed in inputs), the scripts are generally written in a way that verifies correct error handling: unlike typical fuzzers it doesn't check only that the system under test didn't crash, it checks that it returned correct error messages.

You can find ready-to-use scripts testing for many vulnerabilities ( ROBOT, DROWN, etc.) and general standards conformity (RFC 5246, RFC 7627, RFC 7905, etc.) in the scripts/ directory.

Dependencies

You'll need:

  • Python 2.6 or later or Python 3.6 or later
  • tlslite-ng 0.8.0-beta1 or later (note that tlslite will not work and they conflict with each other)
  • ecdsa python module (dependency of tlslite-ng, should get installed automatically with it), use at least version 0.15 for optimal performance

Optionally, to make cryptographic calculations significantly faster, you may want to install the following libraries (see tlslite-ng and python-ecdsa README files for details):

  • m2crypto
  • gmpy

To get pip (if your python installation doesn't already have it) download get-pip.py and run (or see USAGE.md for alternative configuration that does not require installation of packages):

python get-pip.py

Then install tlslite-ng:

pip install --pre tlslite-ng

(Use --upgrade --pre if you did install it before)

Download the tlsfuzzer:

git clone https://github.com/tlsfuzzer/tlsfuzzer.git

Usage

After all dependencies are installed, make sure:

  • you're in the directory of the project (after git clone just cd tlsfuzzer)
  • the server you want to test is running on the same computer (localhost)
  • the server is listening on port 4433
  • and the server will answer with data to HTTP queries (answer with valid HTTP responses is optional)

Then you can run one of the tests in scripts directory, like so:

PYTHONPATH=. python scripts/test-invalid-compression-methods.py

If test has additional requirements, it will output them to console. No errors printed means that all expecations were met (so for tests with bad data the server rejected our messages).

All scripts also accept --help to print the help message (specification of all the options given script supports), -h to specify the hostname or IP address of the server-to-be-tested and -p to specify the port of the service to be tested.

See USAGE.md for more info and how to interpret errors and failures reported by scripts.

You can find mode detailed documentation for the project at tlsfuzzer.readthedocs.io.

Using tlsfuzzer to test for timing side-channel attacks (Lucky13, padding oracle attacks and timing-based Bleichenbacher oracle) is described in the TIMING.md document.

Server under test configuration

In general, the server under test requires just a RSA certificate, you can create it using the following OpenSSL command:

openssl req -x509 -newkey rsa -keyout localhost.key -out localhost.crt -subj \
/CN=localhost -nodes -batch

Note: tlsfuzzer verifies only TLS level behaviour, it does not perform any checks on the certificate (like hostname validation, CA signatures or key usage). It does however verify if the signatures made on TLS message by the server (like in Server Key Exchange or Certificiate Verify message) match the certificate sent by the server.

More detailed instructions, including how to build the different frameworks from source, are available in the Server setup wiki page.

Example server configurations:

OpenSSL

To test OpenSSL, it's sufficient to pass an extra -www option to a typical s_server command line:

openssl s_server -key localhost.key -cert localhost.crt -www

GnuTLS

To test GnuTLS server, you need to tell it to behave as an HTTP server and additionally, to not ask for client certificates:

gnutls-serv --http -p 4433 --x509keyfile localhost.key --x509certfile \
localhost.crt --disable-client-cert

NSS

To test the Mozilla NSS library server, you first need to create a database with server certificate:

mkdir nssdb
certutil -N -d sql:nssdb --empty-password
openssl pkcs12 -export -passout pass: -out localhost.p12 -inkey localhost.key \
-in localhost.crt -name localhost
pk12util -i localhost.p12 -d sql:nssdb -W ''

Finally, start the server with support for TLSv1.0 and later protocols, DHE ciphers and with the above certificate:

selfserv -d sql:./nssdb -p 4433 -V tls1.0: -H 1 -n localhost

Advanced configuration

More advanced and complex configurations as well as description how to compile the above servers from source is available on the wiki page Server setup.

Contributing

See the CONTRIBUTING.md document for description how to set up your development environment, sanity check the changes and requirements the changes need to follow.

You may also want to read the VISION.md to learn more about the planned scope of the project.

Contributors are expected to follow the project's CODE OF CONDUCT when interacting with other members of the community.

tlslite-ng's People

Contributors

almond29 avatar avargarh avatar davidben avatar ep69 avatar fosanzdev avatar frantisekkrenzelok avatar ggonzalez avatar gstarovo avatar inikolcev avatar ioef avatar keesbos avatar kkaarreell avatar loewis avatar marcelofernandez avatar mildas avatar mirkodziadzka avatar morrme avatar noname115 avatar pfalcon avatar ph4r05 avatar postlund avatar pytz avatar rtflynn avatar samrushing avatar simo5 avatar t184256 avatar the-mule avatar theron avatar tomato42 avatar trevp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tlslite-ng's Issues

Testing on PyPy

It looks like all unittests pass on pypy (Python 2.7) so it would be useful to add testing of it to Travis CI, we could then make support for it official.

ECDSA support

Add support for ciphersuites that use ECDSA certificates

Switch from epydoc documentation format

Since epydoc is mostly abandoned now, and we use relative imports, which in turn require a patched version of epydoc.

All of this makes setup for contributing harder.

Refactor ecdsa library and incorporate into tlslite-ng

ecdsa is rather unpythonic (e.g. accessor methods instead of properties) and some of its versions installed on systems we are used may be clobbered (Fedora) or simply old. Doing a refactor of it and incorporating it would make use of tlslite-ng much simpler.

TLS 1.3 support

the protocol is starting to take final shape

  • HKDF algorithm #107
  • RSA-PSS signature algorithm #108
  • session tickets #60
  • key_share extension
  • pre_shared_key extension
  • early data extension
  • cookie extension
  • HelloRetryRequest message
  • EncryptedExtensions message
  • new Certificate message
  • Certificate Verify from server

optionally:

  • support for predefined DHE groups #109
  • x25519 and x448 EdDHE key exchange #89

Contribution details for RHEL

python3-ecdsa, python3-coverage and python3-libs
are named
python34-ecdsa, python34-coverage and python34-libs

Some packages need to be installed with pip. Pip installation file can be downloaded at
https://pip.pypa.io/en/stable/installing/
pip2 is installed with command python get-pip.py
pip3 is installed with command python3 get-pip.py

python3-hypothesis, python-diff-cover, python3-diff-cover and python3-pylint
has to be installed with pip as
diff-cover for pip2
hypothesis, diff-cover and pylint for pip3

clean up keying material extractors

calcExtendedMasterSecret(), calcMasterSecret(), calcFinished(), _calcKeyBlock(), all use essentially the same code, with just different labels. We should move it to single place

Cleanup Parser

tlslite.utils.codec.Parser uses the SyntaxError exception in case the received data can't be parsed as requested.

This is problematic, as the same exception is raised by the runtime environment when there are syntax errors in running code. So a typo in low level code is easy to miss and hard to debug.

Make the Parser raise a TLSLite specific exception in cases like this.

The methods in Parser should also be documented.

Add tests for IPv6/Enable IPv6 support

Support for IPv6 is not certain, having test cases verifying it with all the high level APIs is needed.

Some methods, like _isIP in tlslite/integration/clienthelper.py will certainly need fixing.

test failure

I;m having trouble:

  • Python 2.7.3
  • installed via pip
  • cloned source
  • make test
root@ml ~/tlslite-ng# make test
cd tests/ && python ./tlstest.py server localhost:4433 . & sleep 1
cd tests/ && python ./tlstest.py client localhost:4433 .
Test 0 - anonymous handshake
Test 0 - Anonymous server handshake
Test 1 - good X.509
Test 1 - good X509 (plus SNI)
Traceback (most recent call last):
  File "./tlstest.py", line 1279, in <module>
    clientTestCmd(sys.argv[2:])
  File "./tlstest.py", line 118, in clientTestCmd
    connection.handshakeClientCert(serverName=address[0])
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 350, in handshakeClientCert
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 366, in _handshakeClientAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 545, in _handshakeClientAsyncHelper
    nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 964, in _clientFinished
    for result in self._sendFinished(masterSecret, cipherSuite, nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1847, in _sendFinished
    for result in self._sendMsg(finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 590, in _sendMsg
    for result in self._sendMsgThroughSocket(msgFragment):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 597, in _sendMsgThroughSocket
    for result in self._recordLayer.sendRecord(msg):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 469, in sendRecord
    data = self._encryptThenSeal(data, contentType)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 417, in _encryptThenSeal
    buf = self._writeState.encContext.seal(nonce, buf, authData)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 55, in seal
    otk = self.poly1305_key_gen(self.key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 36, in poly1305_key_gen
    poly = ChaCha(key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 137, in __init__
    self.key = ChaCha._bytearray_to_words(key)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 122, in _bytearray_to_words
    compat26Str(data[i*4:(i+1)*4])))
struct.error: unpack requires a string argument of length 4
make: *** [test] Error 1
root@ml ~/tlslite-ng# Traceback (most recent call last):
  File "./tlstest.py", line 1281, in <module>
    serverTestCmd(sys.argv[2:])
  File "./tlstest.py", line 764, in serverTestCmd
    connection.handshakeServer(certChain=x509Chain, privateKey=x509Key)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1102, in handshakeServer
    nextProtos=nextProtos, anon=anon):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1131, in handshakeServerAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1316, in _handshakeServerAsyncHelper
    nextProtos):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1807, in _serverFinished
    expect_next_protocol=nextProtos is not None):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1895, in _getFinished
    HandshakeType.finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 646, in _getMsg
    for result in self._getNextRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 817, in _getNextRecord
    for result in self._getNextRecordFromSocket():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 841, in _getNextRecordFromSocket
    for result in self._recordLayer.recvRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 695, in recvRecord
    for result in self._recordSocket.recv():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 188, in recv
    for record in self._recvHeader():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 122, in _recvHeader
    for result in self._sockRecvAll(1):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 109, in _sockRecvAll
    raise TLSAbruptCloseError()
tlslite.errors.TLSAbruptCloseError: TLSAbruptCloseError()

running regular example:

root@ml tlslite-ng/tests# tls.py server -k serverX509Key.pem -c serverX509Cert.pem localhost:4443
I am an HTTPS test server, I will listen on localhost:4443
Serving files from /root/tlslite-ng/tests
Using certificate and private key...
About to handshake...
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 48303)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/integration/tlssocketservermixin.py", line 55, in finish_request
    if self.handshake(tlsConnection) == True:
  File "/usr/local/bin/tls.py", line 345, in handshake
    reqCert=reqCert)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1102, in handshakeServer
    nextProtos=nextProtos, anon=anon):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1131, in handshakeServerAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1316, in _handshakeServerAsyncHelper
    nextProtos):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1807, in _serverFinished
    expect_next_protocol=nextProtos is not None):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1895, in _getFinished
    HandshakeType.finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 646, in _getMsg
    for result in self._getNextRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 817, in _getNextRecord
    for result in self._getNextRecordFromSocket():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 841, in _getNextRecordFromSocket
    for result in self._recordLayer.recvRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 695, in recvRecord
    for result in self._recordSocket.recv():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 188, in recv
    for record in self._recvHeader():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 122, in _recvHeader
    for result in self._sockRecvAll(1):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 109, in _sockRecvAll
    raise TLSAbruptCloseError()
TLSAbruptCloseError: TLSAbruptCloseError()
----------------------------------------

Response from client

root@ml tlslite-ng/tests# tls.py client localhost:4443                          Traceback (most recent call last):
  File "/usr/local/bin/tls.py", line 387, in <module>
    clientCmd(sys.argv[2:])
  File "/usr/local/bin/tls.py", line 264, in clientCmd
    settings=settings, serverName=address[0])
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 350, in handshakeClientCert
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 366, in _handshakeClientAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 545, in _handshakeClientAsyncHelper
    nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 964, in _clientFinished
    for result in self._sendFinished(masterSecret, cipherSuite, nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1847, in _sendFinished
    for result in self._sendMsg(finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 590, in _sendMsg
    for result in self._sendMsgThroughSocket(msgFragment):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 597, in _sendMsgThroughSocket
    for result in self._recordLayer.sendRecord(msg):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 469, in sendRecord
    data = self._encryptThenSeal(data, contentType)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 417, in _encryptThenSeal
    buf = self._writeState.encContext.seal(nonce, buf, authData)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 55, in seal
    otk = self.poly1305_key_gen(self.key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 36, in poly1305_key_gen
    poly = ChaCha(key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 137, in __init__
    self.key = ChaCha._bytearray_to_words(key)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 122, in _bytearray_to_words
    compat26Str(data[i*4:(i+1)*4])))
struct.error: unpack requires a string argument of length 4

@tomato42 any help appreciated

Implement 3DES cipher in pure Python

To make the library fully portable, we need to have implementation of 3DES in pure Python, for now we only use it with pycrypto or m2crypto loaded.

Implement certificate signature checking

Allow for loading of a set of CA certificates (or support for the OpenSSL CApath) and verification if the signatures on the certificates were made by the CAs.

verify signatures after making them

since verification of RSA signatures is very inexpensive and failure in signature is usually fatal, make sure that the result of signing is sane

handshake_failure

continuing thread from tlslite, issue 113

call to handshakeClientAnonymous fails with handshake_failure

code used and error backtrace

import socket
from tlslite import TLSConnection
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5)
sock.connect((<ip>,<port>))
c = TLSConnection(socket)
c.handshakeClientAnonymous()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/<python-path>/tlslite/tlsconnection.py", line 243, in handshakeClientAnonymous
    for result in handshaker:
  File "/<python-path>/tlslite/tlsconnection.py", line 439, in _handshakeClientAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/<python-path>/tlslite/tlsconnection.py", line 2060, in _handshakeWrapperAsync
    for result in handshaker:
  File "/<python-path>/tlslite/tlsconnection.py", line 533, in _handshakeClientAsyncHelper
    for result in self._clientGetServerHello(settings, clientHello):
  File "/<python-path>/tlslite/tlsconnection.py", line 687, in _clientGetServerHello
    HandshakeType.server_hello):
  File "/<python-path>/tlslite/tlsrecordlayer.py", line 681, in _getMsg
    raise TLSRemoteAlert(alert)
tlslite.errors.TLSRemoteAlert: handshake_failure
  • using tlslite-ng 0.5.2, not installed but using source python included in larger python project by adding the source code files to python include path
  • python 2.7.5
  • linux 64bit machine using IBM MCP linux flavor
  • kernel 3.10.0-123.20.1
  • no tlslite installed
  • no virtual env in use

stop example server from fragmenting responses

the scripts/tls.py server writes responses line by line (at least the headers do), creating a lot of Application Data fragments and leaks the information about size of headers

it should use some caching mechanism so that if all HTTP data fits in a single record, it should send a single record

Implement protocol renegotiation

For now the renegotiation is rejected on server side and simply unsupported in client side.

When implementing we need to make sure that the certificates and encryption settings stay associated with correct session.

Add support for HKDF algorithm

Add support for the HMAC-based Extract-and-Expand key Derivation Function from RFC 5869

  • test coverage for HMAC methods (HMAC_MD5, HMAC_SHA1, HMAC_SHA256, HMAC_SHA384)
  • universal HMAC method (like secureHash), convert old methods to it
  • HKDF_expand function with test vectors

DSA support

Add support for cipher suites that use DSA certificates for authentication.

TypeError in SRP example

after connecting using

tls.py client -u alice -p abra123cadabra localhost:4443 

(incorrectly syntaxed in README)

Server:

tls.py server -v verifierDB localhost:4443
I am an HTTPS test server, I will listen on localhost:4443
Serving files from /home/sander/src/tlslite-ng/tests
Using verifier DB...
About to handshake...
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 36312)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/integration/tlssocketservermixin.py", line 55, in finish_request
    if self.handshake(tlsConnection) == True:
  File "/usr/local/bin/tls.py", line 345, in handshake
    reqCert=reqCert)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1102, in handshakeServer
    nextProtos=nextProtos, anon=anon):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1131, in handshakeServerAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1264, in _handshakeServerAsyncHelper
    settings):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1575, in _serverSRPKeyExchange
    serverKeyExchange = keyExchange.makeServerKeyExchange(sigHash)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/keyexchange.py", line 406, in makeServerKeyExchange
    entry = self.verifierDB[srpUsername]
  File "/usr/local/lib/python2.7/dist-packages/tlslite/basedb.py", line 59, in __getitem__
    valueStr = self.db[username]
  File "/usr/lib/python2.7/bsddb/__init__.py", line 270, in __getitem__
    return _DeadlockWrap(lambda: self.db[key])  # self.db[key]
  File "/usr/lib/python2.7/bsddb/dbutils.py", line 68, in DeadlockWrap
    return function(*_args, **_kwargs)
  File "/usr/lib/python2.7/bsddb/__init__.py", line 270, in <lambda>
    return _DeadlockWrap(lambda: self.db[key])  # self.db[key]
TypeError: String or Integer object expected for key, unicode found
----------------------------------------

Tested on Python 2.7.12 and Python 2.7.3

Refactor tlstest.py

The current integration testing code could benefit from some refactoring. The auto-numbering is a massive improvement, but there's still some minor annoyances:

  • The output isn't intuitive, particularly for the fault-injection tests. Printing 'pass' or 'ok' after each successful test would be an improvement, but isn't really feasible without changing how output is handled (at the moment both the client and server share stdout).
    • Fault injection tests indicate success with strings like 'Good Fault bad padding' which is obscure and could be interpreted as meaning the test failed, particularly since most tests don't produce any output at all.
  • Several tests have different names on the client and server (e.g. test 0 is called 'anonymous handshake' on the client and 'Anonymous server handshake' on the server).
  • Typically only one end of the connection crashes, and the other then falls over with an unrelated error ('Connection Refused' or 'TLSAbruptCloseError'). It's generally obvious which end failed, but it's still less than ideal.
  • If testing is interrupted (e.g. with SIGINT/ctrl-C) or something causes the tlstest client to crash, the server can be left running which causes subsequent make test runs to fail ('Address already in use'). The exact circumstances for triggering this are unclear, beyond getting (un)lucky when you abort the test.

One option that comes to mind is to rewrite the tests to use the async API, which would remove the need for separate client and server processes. Testing could then be managed with the unittest module, to be consistent with the unit tests. Seem reasonable?

Also, a couple of minor notes related to testing in general:

  • Running unit tests on Python 2 requires the 'mock' module to be installed, this doesn't appear to be in the list of requirements in CONTRIBUTING.md. Likewise, epydoc (and the associated modifications) are also missing from the list.
  • The current make test target doesn't seem particularly useful given that it's undocumented and tests the installed copy of tlslite instead of the local copy. It also doesn't run unit tests and only runs the test on the default python. Perhaps the 'test' and 'test-local' targets should be removed, and 'test-dev' split up so that 'test' can invoke the unit/integration tests without running the linter/coverage checker.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.