def _use_certificate_chain_file_test(self, certdir):
    '\n        Verify that `Context.use_certificate_chain_file` reads a\n        certificate chain from a specified file.\n\n        The chain is tested by starting a server with scert and connecting to\n        it with a client which trusts cacert and requires verification to\n        succeed.\n        '
    chain = _create_certificate_chain()
    [(cakey, cacert), (ikey, icert), (skey, scert)] = chain
    makedirs(certdir)
    chainFile = join_bytes_or_unicode(certdir, 'chain.pem')
    caFile = join_bytes_or_unicode(certdir, 'ca.pem')
    with open(chainFile, 'wb') as fObj:
        fObj.write(dump_certificate(FILETYPE_PEM, scert))
        fObj.write(dump_certificate(FILETYPE_PEM, icert))
        fObj.write(dump_certificate(FILETYPE_PEM, cacert))
    with open(caFile, 'w') as fObj:
        fObj.write(dump_certificate(FILETYPE_PEM, cacert).decode('ascii'))
    serverContext = Context(TLSv1_METHOD)
    serverContext.use_certificate_chain_file(chainFile)
    serverContext.use_privatekey(skey)
    clientContext = Context(TLSv1_METHOD)
    clientContext.set_verify((VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT), verify_cb)
    clientContext.load_verify_locations(caFile)
    self._handshake_test(serverContext, clientContext)
Verify that `Context.use_certificate_chain_file` reads a
certificate chain from a specified file.

The chain is tested by starting a server with scert and connecting to
it with a client which trusts cacert and requires verification to
succeed.
def _use_certificate_chain_file_test(self, certdir):
    '\n        Verify that `Context.use_certificate_chain_file` reads a\n        certificate chain from a specified file.\n\n        The chain is tested by starting a server with scert and connecting to\n        it with a client which trusts cacert and requires verification to\n        succeed.\n        '
    chain = _create_certificate_chain()
    [(cakey, cacert), (ikey, icert), (skey, scert)] = chain
    makedirs(certdir)
    chainFile = join_bytes_or_unicode(certdir, 'chain.pem')
    caFile = join_bytes_or_unicode(certdir, 'ca.pem')
    with open(chainFile, 'wb') as fObj:
        fObj.write(dump_certificate(FILETYPE_PEM, scert))
        fObj.write(dump_certificate(FILETYPE_PEM, icert))
        fObj.write(dump_certificate(FILETYPE_PEM, cacert))
    with open(caFile, 'w') as fObj:
        fObj.write(dump_certificate(FILETYPE_PEM, cacert).decode('ascii'))
    serverContext = Context(TLSv1_METHOD)
    serverContext.use_certificate_chain_file(chainFile)
    serverContext.use_privatekey(skey)
    clientContext = Context(TLSv1_METHOD)
    clientContext.set_verify((VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT), verify_cb)
    clientContext.load_verify_locations(caFile)
    self._handshake_test(serverContext, clientContext)