@@ -477,46 +477,46 @@ def test_set_sigalgs_list_wrong_type(self, context):
477
477
with pytest .raises (TypeError ):
478
478
context .set_sigalgs_list (object ())
479
479
480
- def test_set_sigalgs_list_invalid_name (self , context ):
481
- """
482
- `Context.set_cipher_list` raises `OpenSSL.SSL.Error` with a
483
- `"no cipher match"` reason string regardless of the TLS
484
- version.
485
- """
486
- with pytest .raises (Error ):
487
- context .set_sigalgs_list (b"imaginary-sigalg" )
488
-
489
- def test_set_sigalgs_list_not_supported (self ):
490
- """
491
- If no signature algorithms supported by the server are set, the handshake
492
- fails with a `"no suitable signature algorithm"` reason string.
493
- """
480
+ if _lib .Cryptography_HAS_SIGALGS :
481
+ def test_set_sigalgs_list_invalid_name (self , context ):
482
+ """
483
+ `Context.set_cipher_list` raises `OpenSSL.SSL.Error` with a
484
+ `"no cipher match"` reason string regardless of the TLS
485
+ version.
486
+ """
487
+ with pytest .raises (Error ):
488
+ context .set_sigalgs_list (b"imaginary-sigalg" )
494
489
495
- def make_client (socket ):
496
- context = Context (TLSv1_2_METHOD )
497
- context .set_sigalgs_list (b"ECDSA+SHA256:ECDSA+SHA384" )
498
- c = Connection (context , socket )
499
- c .set_connect_state ()
500
- return c
490
+ def test_set_sigalgs_list_not_supported (self ):
491
+ """
492
+ If no signature algorithms supported by the server are set, the handshake
493
+ fails with a `"no suitable signature algorithm"` reason string.
494
+ """
501
495
502
- with pytest .raises (Error ) as excinfo :
503
- loopback (client_factory = make_client )
504
- assert excinfo .value .args == (
505
- [
506
- (
507
- 'SSL routines' ,
508
- 'tls_choose_sigalg' ,
509
- 'no suitable signature algorithm' ,
510
- ),
511
- ],
512
- )
496
+ def make_client (socket ):
497
+ context = Context (TLSv1_2_METHOD )
498
+ context .set_sigalgs_list (b"ECDSA+SHA256:ECDSA+SHA384" )
499
+ c = Connection (context , socket )
500
+ c .set_connect_state ()
501
+ return c
502
+
503
+ with pytest .raises (Error ) as excinfo :
504
+ loopback (client_factory = make_client )
505
+ assert excinfo .value .args == (
506
+ [
507
+ (
508
+ 'SSL routines' ,
509
+ 'tls_choose_sigalg' ,
510
+ 'no suitable signature algorithm' ,
511
+ ),
512
+ ],
513
+ )
513
514
514
515
def test_get_sigalgs (self ):
515
516
"""
516
517
`Connection.get_sigalgs` returns the signature algorithms send by the client to the server.
517
518
This is supported only in TLS1_2 and later.
518
519
"""
519
-
520
520
def make_client (socket ):
521
521
context = Context (TLSv1_2_METHOD )
522
522
context .set_sigalgs_list (b"RSA-PSS+SHA256:ECDSA+SHA384" )
@@ -529,8 +529,12 @@ def make_client(socket):
529
529
client_factory = make_client )
530
530
531
531
sigalgs = srv .get_sigalgs ()
532
- assert 0x0804 in sigalgs # rsa_pss_rsae_sha256
533
- assert 0x0503 in sigalgs # ecdsa_secp384r1_sha384
532
+ if _lib .Cryptography_HAS_SIGALGS :
533
+ assert 0x0804 in sigalgs # rsa_pss_rsae_sha256
534
+ assert 0x0503 in sigalgs # ecdsa_secp384r1_sha384
535
+ else :
536
+ # gracefully degrades on older OpenSSL versions
537
+ assert len (sigalgs ) == 0
534
538
535
539
def test_load_client_ca (self , context , ca_file ):
536
540
"""
0 commit comments