'Start TLS negotiation.
This checks if the receiving entity requires TLS, the SSL library is
available and uses the C{required} and C{wanted} instance variables to
determine what to do in the various different cases.
For example, if the SSL library is not available, and wanted and
required by the user, it raises an exception. However if it is not
required by both parties, initialization silently succeeds, moving
on to the next step.'

def start(self):

    if self.wanted:
        if (ssl is None):
            if self.required:
                return defer.fail(TLSNotSupported())
            else:
                return defer.succeed(None)
        else:
            pass
    elif self.xmlstream.features[self.feature].required:
        return defer.fail(TLSRequired())
    else:
        return defer.succeed(None)
    self._deferred = defer.Deferred()
    self.xmlstream.addOnetimeObserver('/proceed', self.onProceed)
    self.xmlstream.addOnetimeObserver('/failure', self.onFailure)
    self.xmlstream.send(domish.Element((NS_XMPP_TLS, 'starttls')))
    return self._deferred
