Skip to content

Commit ed0f6ed

Browse files
tiranencukou
authored andcommitted
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. python-ldap#92 Closes: python-ldap#87 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent 5687863 commit ed0f6ed

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Tests/t_cext.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,16 @@ def test_tls_ext_noca(self):
833833
l.set_option(_ldap.OPT_PROTOCOL_VERSION, _ldap.VERSION3)
834834
with self.assertRaises(_ldap.CONNECT_ERROR) as e:
835835
l.start_tls_s()
836-
# some platforms return '(unknown error code)' as reason
837-
if '(unknown error code)' not in str(e.exception):
838-
self.assertIn('not trusted', str(e.exception))
836+
# known resaons:
837+
# Ubuntu on Travis: '(unknown error code)'
838+
# OpenSSL 1.1: error:1416F086:SSL routines:\
839+
# tls_process_server_certificate:certificate verify failed
840+
# NSS: TLS error -8172:Peer's certificate issuer has \
841+
# been marked as not trusted by the user.
842+
msg = str(e.exception)
843+
candidates = ('certificate', 'tls', '(unknown error code)')
844+
if not any(s in msg.lower() for s in candidates):
845+
self.fail(msg)
839846

840847
@requires_tls(skip_nss=True)
841848
def test_tls_ext_clientcert(self):

0 commit comments

Comments
 (0)