def test_txt2obj(self): import _ssl assert _ssl.txt2obj('serverAuth', name=True) == ( 129, 'serverAuth', 'TLS Web Server Authentication', '1.3.6.1.5.5.7.3.1') raises(ValueError, _ssl.txt2obj, 'serverAuth', name=False) assert _ssl.txt2obj('1.3.6.1.5.5.7.3.1', name=True) == ( 129, 'serverAuth', 'TLS Web Server Authentication', '1.3.6.1.5.5.7.3.1')
def test_txt2obj(self): import _ssl assert _ssl.txt2obj('serverAuth', name=True) == (129, 'serverAuth', 'TLS Web Server Authentication', '1.3.6.1.5.5.7.3.1') raises(ValueError, _ssl.txt2obj, 'serverAuth', name=False) assert _ssl.txt2obj('1.3.6.1.5.5.7.3.1', name=True) == (129, 'serverAuth', 'TLS Web Server Authentication', '1.3.6.1.5.5.7.3.1')
def rdn_shortname(key): try: short = _ssl.txt2obj(key, True)[1] except (ValueError, KeyError): return key if short: return short else: return key