Skip to content

Commit

Permalink
promote HandshakeSettings._getCertificateTypes to public
Browse files Browse the repository at this point in the history
the method is only used by external classes so it should be public
  • Loading branch information
tomato42 committed Mar 24, 2015
1 parent 6f6f2ac commit a9f92d4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
9 changes: 5 additions & 4 deletions tlslite/handshakesettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ def validate(self):

return other

def _getCertificateTypes(self):
l = []
def getCertificateTypes(self):
"""Get list of certificate types as IDs"""
ret = []
for ct in self.certificateTypes:
if ct == "x509":
l.append(CertificateType.x509)
ret.append(CertificateType.x509)
else:
raise AssertionError()
return l
return ret
2 changes: 1 addition & 1 deletion tlslite/tlsconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def _clientSendClientHello(self, settings, session, srpUsername,
wireCipherSuites.append(CipherSuite.TLS_FALLBACK_SCSV)

#Initialize acceptable certificate types
certificateTypes = settings._getCertificateTypes()
certificateTypes = settings.getCertificateTypes()

#Either send ClientHello (with a resumable session)...
if session and session.sessionID:
Expand Down
12 changes: 12 additions & 0 deletions unit_tests/test_tlslite_handshakesettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,15 @@ def test_maxVersion_without_TLSv1_2(self):
new_hs = hs.validate()

self.assertFalse("sha256" in new_hs.macNames)

def test_getCertificateTypes(self):
hs = HandshakeSettings()

self.assertEqual([0], hs.getCertificateTypes())

def test_getCertificateTypes_with_unsupported_type(self):
hs = HandshakeSettings()
hs.certificateTypes = ["x509", "openpgp"]

with self.assertRaises(AssertionError):
hs.getCertificateTypes()

0 comments on commit a9f92d4

Please sign in to comment.