Skip to content

Commit 157eec5

Browse files
committed
Accept more error messages in test_tls_ext_noca
OpenSSL 1.0, 1.1, and NSS return different error messages for untrusted certificate and missing CA. Closes: #87 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent 9f86c06 commit 157eec5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Tests/t_cext.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,16 @@ def test_tls_ext_noca(self):
818818
l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3)
819819
with self.assertRaises(_ldap.CONNECT_ERROR) as e:
820820
l.start_tls_s()
821-
# some platforms return '(unknown error code)' as reason
822-
if '(unknown error code)' not in str(e.exception):
823-
self.assertIn('not trusted', str(e.exception))
821+
# known resaons:
822+
# Ubuntu on Travis: '(unknown error code)'
823+
# OpenSSL 1.1: error:1416F086:SSL routines:\
824+
# tls_process_server_certificate:certificate verify failed
825+
# NSS: TLS error -8172:Peer's certificate issuer has \
826+
# been marked as not trusted by the user.
827+
msg = str(e.exception)
828+
candidates = ('certificate', 'tls', '(unknown error code)')
829+
if not any(s in msg.lower() for s in candidates):
830+
self.fail(msg)
824831

825832
@requires_tls(skip_nss=True)
826833
def test_tls_ext_clientcert(self):

0 commit comments

Comments
 (0)