@@ -574,9 +574,9 @@ def existing_cert(x509, cert_args, ca_key, rsa_privkey, request):
574574 ca_key ,
575575 encoding = cert_args .get ("encoding" , "pem" ),
576576 passphrase = cert_args .get ("pkcs12_passphrase" ),
577- subject = subject
578- if "signing_policy" not in cert_args
579- else "CN=from_signing_policy" ,
577+ subject = (
578+ subject if "signing_policy" not in cert_args else "CN=from_signing_policy"
579+ ) ,
580580 )
581581 yield cert_args ["name" ]
582582
@@ -694,8 +694,12 @@ def existing_csr_exts(x509, csr_args, csr_args_exts, ca_key, rsa_privkey, reques
694694def existing_pk (x509 , pk_args , request ):
695695 pk_args .update (request .param )
696696 ret = x509 .private_key_managed (** pk_args )
697- if ret .result == False and "UnsupportedAlgorithm" in ret .comment :
698- pytest .skip (f"Algorithm '{ pk_args ['algo' ]} ' is not supported on this OpenSSL version" )
697+ if ret .result == False and (
698+ "UnsupportedAlgorithm" in ret .comment or "NotImplementedError" in ret .comment
699+ ):
700+ pytest .skip (
701+ f"Algorithm '{ pk_args ['algo' ]} ' is not supported on this OpenSSL version"
702+ )
699703 _assert_pk_basic (
700704 ret ,
701705 pk_args .get ("algo" , "rsa" ),
@@ -1054,6 +1058,8 @@ def test_certificate_managed_days_valid_does_not_override_days_remaining(
10541058def test_certificate_managed_privkey_change (x509 , cert_args , ec_privkey , ca_key ):
10551059 cert_args ["private_key" ] = ec_privkey
10561060 ret = x509 .certificate_managed (** cert_args )
1061+ if ret .result == False and "NotImplementedError" in ret .comment :
1062+ pytest .skip ("Current OpenSSL does not support 'ec' algorithm" )
10571063 _assert_cert_basic (ret , cert_args ["name" ], ec_privkey , ca_key )
10581064 assert ret .changes ["private_key" ]
10591065
@@ -1237,6 +1243,8 @@ def test_certificate_managed_wrong_ca_key(
12371243 cert_args ["private_key" ] = ec_privkey
12381244 cert_args ["signing_private_key" ] = rsa_privkey
12391245 ret = x509 .certificate_managed (** cert_args )
1246+ if ret .result == False and "NotImplementedError" in ret .comment :
1247+ pytest .skip ("Current OpenSSL does not support 'ec' algorithm" )
12401248 assert ret .result is False
12411249 assert not ret .changes
12421250 assert "Signing private key does not match the certificate" in ret .comment
@@ -1917,6 +1925,8 @@ def test_csr_managed_existing_invalid_version(x509, csr_args, rsa_privkey):
19171925def test_csr_managed_privkey_change (x509 , csr_args , ec_privkey ):
19181926 csr_args ["private_key" ] = ec_privkey
19191927 ret = x509 .csr_managed (** csr_args )
1928+ if ret .result == False and "NotImplementedError" in ret .comment :
1929+ pytest .skip ("Current OpenSSL does not support 'ec' algorithm" )
19201930 _assert_csr_basic (ret , ec_privkey )
19211931 assert ret .changes ["private_key" ]
19221932
@@ -2141,11 +2151,14 @@ def test_private_key_managed(x509, pk_args, algo, encoding, passphrase):
21412151 pytest .skip (
21422152 "PKCS12 serialization of Edwards-curve keys requires cryptography v37"
21432153 )
2154+
21442155 pk_args ["algo" ] = algo
21452156 pk_args ["encoding" ] = encoding
21462157 pk_args ["passphrase" ] = passphrase
21472158 ret = x509 .private_key_managed (** pk_args )
2148- if ret .result == False and "UnsupportedAlgorithm" in ret .comment :
2159+ if ret .result == False and (
2160+ "UnsupportedAlgorithm" in ret .comment or "NotImplementedError" in ret .comment
2161+ ):
21492162 pytest .skip (f"Algorithm '{ algo } ' is not supported on this OpenSSL version" )
21502163 _assert_pk_basic (ret , algo , encoding , passphrase )
21512164
@@ -2155,6 +2168,8 @@ def test_private_key_managed_keysize(x509, pk_args, algo, keysize):
21552168 pk_args ["algo" ] = algo
21562169 pk_args ["keysize" ] = keysize
21572170 ret = x509 .private_key_managed (** pk_args )
2171+ if ret .result == False and "NotImplementedError" in ret .comment :
2172+ pytest .skip ("Current OpenSSL does not support 'ec' algorithm" )
21582173 pk = _assert_pk_basic (ret , algo )
21592174 assert pk .key_size == keysize
21602175
@@ -2174,8 +2189,12 @@ def test_private_key_managed_keysize(x509, pk_args, algo, keysize):
21742189)
21752190def test_private_key_managed_existing (x509 , pk_args ):
21762191 ret = x509 .private_key_managed (** pk_args )
2177- if ret .result == False and "UnsupportedAlgorithm" in ret .comment :
2178- pytest .skip (f"Algorithm '{ pk_args ['algo' ]} ' is not supported on this OpenSSL version" )
2192+ if ret .result == False and (
2193+ "UnsupportedAlgorithm" in ret .comment or "NotImplementedError" in ret .comment
2194+ ):
2195+ pytest .skip (
2196+ f"Algorithm '{ pk_args ['algo' ]} ' is not supported on this OpenSSL version"
2197+ )
21792198 _assert_not_changed (ret )
21802199
21812200
@@ -2382,6 +2401,8 @@ def test_private_key_managed_follow_symlinks_changes(
23822401 pk_args ["encoding" ] = encoding
23832402 pk_args ["algo" ] = "ec"
23842403 ret = x509 .private_key_managed (** pk_args )
2404+ if ret .result == False and "NotImplementedError" in ret .comment :
2405+ pytest .skip ("Current OpenSSL does not support 'ec' algorithm" )
23852406 assert ret .changes
23862407 assert Path (ret .name ).is_symlink () == follow
23872408
@@ -2722,7 +2743,12 @@ def _get_cert(cert, encoding="pem", passphrase=None):
27222743def _belongs_to (cert_or_pubkey , privkey ):
27232744 if isinstance (cert_or_pubkey , cx509 .Certificate ):
27242745 cert_or_pubkey = cert_or_pubkey .public_key ()
2725- return x509util .is_pair (cert_or_pubkey , x509util .load_privkey (privkey ))
2746+ try :
2747+ return x509util .is_pair (cert_or_pubkey , x509util .load_privkey (privkey ))
2748+ except NotImplementedError :
2749+ pytest .skip (
2750+ "This OpenSSL version does not support current cryptographic algorithm"
2751+ )
27262752
27272753
27282754def _signed_by (cert , privkey ):
0 commit comments