def __new__( cls: Type['SSL'], transport: Transport, domain: SSLDomain, session_details: Optional['SSLSessionDetails'] = None) -> 'SSL': """Enforce a singleton SSL object per Transport""" if transport._ssl: # unfortunately, we've combined the allocation and the configuration in a # single step. So catch any attempt by the application to provide what # may be a different configuration than the original (hack) ssl = transport._ssl if (domain and (ssl._domain is not domain) or session_details and (ssl._session_details is not session_details)): raise SSLException("Cannot re-configure existing SSL object!") else: obj = super(SSL, cls).__new__(cls) obj._domain = domain obj._session_details = session_details session_id = None if session_details: session_id = session_details.get_session_id() obj._ssl = pn_ssl(transport._impl) if obj._ssl is None: raise SSLUnavailable() if domain: pn_ssl_init(obj._ssl, domain._domain, session_id) transport._ssl = obj return transport._ssl
def __new__(cls, transport, domain, session_details=None): """Enforce a singleton SSL object per Transport""" if transport._ssl: # unfortunately, we've combined the allocation and the configuration in a # single step. So catch any attempt by the application to provide what # may be a different configuration than the original (hack) ssl = transport._ssl if (domain and (ssl._domain is not domain) or session_details and (ssl._session_details is not session_details)): raise SSLException("Cannot re-configure existing SSL object!") else: obj = super(SSL, cls).__new__(cls) obj._domain = domain obj._session_details = session_details session_id = None if session_details: session_id = session_details.get_session_id() obj._ssl = pn_ssl(transport._impl) if obj._ssl is None: raise SSLUnavailable() if domain: pn_ssl_init(obj._ssl, domain._domain, session_id) transport._ssl = obj return transport._ssl