diff options
Diffstat (limited to 'tests/test_ssl.py')
| -rw-r--r-- | tests/test_ssl.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_ssl.py b/tests/test_ssl.py index b09fce7..0831904 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -2418,6 +2418,31 @@ class TestConnection(object): with pytest.raises(NotImplementedError): conn.makefile() + def test_get_certificate(self): + """ + `Connection.get_certificate` returns the local certificate. + """ + chain = _create_certificate_chain() + [(cakey, cacert), (ikey, icert), (skey, scert)] = chain + + context = Context(TLSv1_METHOD) + context.use_certificate(scert) + client = Connection(context, None) + cert = client.get_certificate() + assert cert is not None + assert "Server Certificate" == cert.get_subject().CN + + def test_get_certificate_none(self): + """ + `Connection.get_certificate` returns the local certificate. + + If there is no certificate, it returns None. + """ + context = Context(TLSv1_METHOD) + client = Connection(context, None) + cert = client.get_certificate() + assert cert is None + def test_get_peer_cert_chain(self): """ `Connection.get_peer_cert_chain` returns a list of certificates |
