def test_add_extra_chain_cert(self, tmpdir):
    '\n        `Context.add_extra_chain_cert` accepts an `X509`\n        instance to add to the certificate chain.\n\n        See `_create_certificate_chain` for the details of the\n        certificate chain tested.\n\n        The chain is tested by starting a server with scert and connecting\n        to 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
    for (cert, name) in [(cacert, 'ca.pem'), (icert, 'i.pem'), (scert, 's.pem')]:
        with tmpdir.join(name).open('w') as f:
            f.write(dump_certificate(FILETYPE_PEM, cert).decode('ascii'))
    for (key, name) in [(cakey, 'ca.key'), (ikey, 'i.key'), (skey, 's.key')]:
        with tmpdir.join(name).open('w') as f:
            f.write(dump_privatekey(FILETYPE_PEM, key).decode('ascii'))
    serverContext = Context(TLSv1_METHOD)
    serverContext.use_privatekey(skey)
    serverContext.use_certificate(scert)
    serverContext.add_extra_chain_cert(icert)
    clientContext = Context(TLSv1_METHOD)
    clientContext.set_verify((VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT), verify_cb)
    clientContext.load_verify_locations(str(tmpdir.join('ca.pem')))
    self._handshake_test(serverContext, clientContext)
`Context.add_extra_chain_cert` accepts an `X509`
instance to add to the certificate chain.

See `_create_certificate_chain` for the details of the
certificate chain tested.

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 test_add_extra_chain_cert(self, tmpdir):
    '\n        `Context.add_extra_chain_cert` accepts an `X509`\n        instance to add to the certificate chain.\n\n        See `_create_certificate_chain` for the details of the\n        certificate chain tested.\n\n        The chain is tested by starting a server with scert and connecting\n        to 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
    for (cert, name) in [(cacert, 'ca.pem'), (icert, 'i.pem'), (scert, 's.pem')]:
        with tmpdir.join(name).open('w') as f:
            f.write(dump_certificate(FILETYPE_PEM, cert).decode('ascii'))
    for (key, name) in [(cakey, 'ca.key'), (ikey, 'i.key'), (skey, 's.key')]:
        with tmpdir.join(name).open('w') as f:
            f.write(dump_privatekey(FILETYPE_PEM, key).decode('ascii'))
    serverContext = Context(TLSv1_METHOD)
    serverContext.use_privatekey(skey)
    serverContext.use_certificate(scert)
    serverContext.add_extra_chain_cert(icert)
    clientContext = Context(TLSv1_METHOD)
    clientContext.set_verify((VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT), verify_cb)
    clientContext.load_verify_locations(str(tmpdir.join('ca.pem')))
    self._handshake_test(serverContext, clientContext)