def test_chainCerts(self): """ L{chainCerts} loads all but the first cert in a file. """ data = FilePath(__file__).sibling('data').child('certs') cert1 = data.child('cert1.pem').getContent() cert2 = data.child('cert2.pem').getContent() cert3 = data.child('cert3.pem').getContent() expected = [ Certificate.loadPEM(cert) for cert in [cert2, cert3]] chain = chainCerts(cert1 + '\n' + cert2 + '\n' + cert3) self.assertEqual(len(chain), 2) self.assertEqual( chain[0].digest('sha256'), expected[0].digest('sha256')) self.assertEqual( chain[1].digest('sha256'), expected[1].digest('sha256'))
def _serviceDescription(self): """ Produce a description of the service we should start. """ ca = Certificate.loadPEM( FilePath(self.caPath.encode('utf-8')).getContent()) certBytes = FilePath(self.certPath.encode('utf-8')).getContent() cert = PrivateCertificate.loadPEM(certBytes) # Can't use PrivateCertificate.options until Twisted #6361 is fixed options = CertificateOptions( privateKey=cert.privateKey.original, certificate=cert.original, trustRoot=ca, extraCertChain=chainCerts(certBytes)) router = IndexRouter(store=self.store) return _ServiceDescription( reactor=reactor, port=self.port, interface=self.interface, options=options, router=router)