diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py index c2be93fe1..e95e89cea 100644 --- a/src/OpenSSL/SSL.py +++ b/src/OpenSSL/SSL.py @@ -1222,10 +1222,12 @@ def set_sigalgs_list(self, sigalgs_list): if not isinstance(sigalgs_list, bytes): raise TypeError("sigalgs_list must be a byte string.") - if _lib.Cryptography_HAS_SIGALGS: - _openssl_assert( - _lib.SSL_CTX_set1_sigalgs_list(self._context, sigalgs_list) == 1 - ) + if not _lib.Cryptography_HAS_SIGALGS: + return + + _openssl_assert( + _lib.SSL_CTX_set1_sigalgs_list(self._context, sigalgs_list) == 1 + ) def set_client_ca_list(self, certificate_authorities): """ @@ -2041,7 +2043,7 @@ def get_cipher_list(self): def get_sigalgs(self): """ - Retrieve the list of signature algorithms used by the Connection object. + Retrieve list of signature algorithms used by the Connection object. Must be used after handshake only. See :manpage:`SSL_get_sigalgs(3)`. diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 00e475848..2c12300f0 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -489,9 +489,9 @@ def test_set_sigalgs_list_invalid_name(self, context): def test_set_sigalgs_list_not_supported(self): """ - If no signature algorithms supported by the server are set, the handshake - fails with a `"no suitable signature algorithm"` reason string, - or 'no shared cipher' on older OpenSSL releases. + If no signature algorithms supported by the server are set, + the handshake fails with a `"no suitable signature algorithm"` + reason string, or 'no shared cipher' on older OpenSSL releases. """ def make_client(socket): @@ -506,8 +506,8 @@ def make_client(socket): def test_get_sigalgs(self): """ - `Connection.get_sigalgs` returns the signature algorithms send by the client to the server. - This is supported only in TLS1_2 and later. + `Connection.get_sigalgs` returns the signature algorithms send by + the client to the server. This is supported only in TLS1_2 and later. """ def make_client(socket): context = Context(TLSv1_2_METHOD) @@ -517,7 +517,8 @@ def make_client(socket): return c srv, client = loopback( - server_factory=lambda s: loopback_server_factory(s, TLSv1_2_METHOD), + server_factory=lambda s: loopback_server_factory(s, + TLSv1_2_METHOD), client_factory=make_client) sigalgs = srv.get_sigalgs()