'Create an OpenSSL connection and set it up good.
@param tlsProtocol: The protocol which is establishing the connection.
@type tlsProtocol: L{TLSMemoryBIOProtocol}
@return: an OpenSSL connection object for C{tlsProtocol} to use
@rtype: L{OpenSSL.SSL.Connection}'

def _createConnection(self, tlsProtocol):

    connectionCreator = self._connectionCreator
    if (self._creatorInterface is IOpenSSLClientConnectionCreator):
        connection = connectionCreator.clientConnectionForTLS(tlsProtocol)
        self._applyProtocolNegotiation(connection)
        connection.set_connect_state()
    else:
        connection = connectionCreator.serverConnectionForTLS(tlsProtocol)
        self._applyProtocolNegotiation(connection)
        connection.set_accept_state()
    return connection
