def protocolNegotiationMechanisms():
 support = ProtocolNegotiationSupport.NOSUPPORT
 ctx = SSL.Context(SSL.SSLv23_METHOD)
 try:
  ctx.set_npn_advertise_callback((lambda c: None))
 except (AttributeError, NotImplementedError):
  pass
 else:
  support |= ProtocolNegotiationSupport.NPN
 try:
  ctx.set_alpn_select_callback((lambda c: None))
 except (AttributeError, NotImplementedError):
  pass
 else:
  support |= ProtocolNegotiationSupport.ALPN
 return support

def protocolNegotiationMechanisms ( ) : support = ProtocolNegotiationSupport . NOSUPPORT ctx = SSL . Context ( SSL . SSLv23_METHOD ) try : ctx . set_npn_advertise_callback ( ( lambda c : None ) ) except ( AttributeError , NotImplementedError ) : pass else : support |= ProtocolNegotiationSupport . NPN try : ctx . set_alpn_select_callback ( ( lambda c : None ) ) except ( AttributeError , NotImplementedError ) : pass else : support |= ProtocolNegotiationSupport . ALPN return support
checks whether your versions of pyopenssl and openssl are recent enough to support protocol negotiation .