def _secure(self, to, From, authorize):
        if self.hostCertificate is not None:
            raise RuntimeError("Re-encrypting already encrypted connection")
        CS = self.service.certificateStorage
        ourCert = CS.getPrivateCertificate(str(to.domainAddress()))
        if authorize:
            D = CS.getSelfSignedCertificate(str(From.domainAddress()))
        else:
            self.authorized = False
            return {'tls_localCertificate': ourCert}

        def hadCert(peerSigned):
            self.authorized = True
            self._cacheMeNow(From, to, authorize)
            return {'tls_localCertificate': ourCert,
                    'tls_verifyAuthorities': [peerSigned]}

        def didNotHaveCert(err):
            err.trap(KeyError)
            return self._retrieveRemoteCertificate(From, port)

        D.addErrback(didNotHaveCert)
        D.addCallback(hadCert)

        return D
Response to a SECURE command, starting TLS when necessary, and using a
dataset/ETHPy150Open twisted/vertex/vertex/q2q.py/Q2Q._secure