Ticket #2061: chained-certs-2061-feedback-2.patch

File chained-certs-2061-feedback-2.patch, 2.7 KB (added by Hynek Schlawack, 7 years ago)
  • twisted/internet/_sslverify.py

    diff --git twisted/internet/_sslverify.py twisted/internet/_sslverify.py
    index da9e080..e531013 100644
    class OpenSSLCertificateOptions(object): 
    721721        if extraCertChain is not None and None in (privateKey, certificate):
    722722            raise ValueError("A private key and a certificate are required "
    723723                             "when adding a supplemental certificate chain.")
    724         self.extraCertChain = extraCertChain or []
     724        if extraCertChain is not None:
     725            self.extraCertChain = extraCertChain
     726        else:
     727            self.extraCertChain = []
    725728
    726729        self.caCerts = caCerts
    727730        self.verifyDepth = verifyDepth
  • twisted/test/test_sslverify.py

    diff --git twisted/test/test_sslverify.py twisted/test/test_sslverify.py
    index 69d3856..3b64b44 100644
    class WritingProtocol(protocol.Protocol): 
    121121
    122122class FakeContext:
    123123    """
    124     Fake of an C{OpenSSL.SSL.Context}.
     124    Introspectable fake of an C{OpenSSL.SSL.Context}.
    125125
    126126    Saves call arguments for later introspection.
     127
     128    Necessary because C{Context} offers poor introspection.  cf. this
     129    U{pyOpenSSL bug<https://bugs.launchpad.net/pyopenssl/+bug/1173899>}.
     130
     131    @ivar _method: See C{method} parameter of L{__init__}.
     132    @ivar _options: C{int} of C{OR}ed values from calls of L{set_options}.
     133    @ivar _certificate: Set by L{use_certificate}.
     134    @ivar _privateKey: Set by L{use_privatekey}.
     135    @ivar _verify: Set by L{set_verify}.
     136    @ivar _verifyDepth: Set by L{set_verify_depth}.
     137    @ivar _sessionID: Set by L{set_session_id}.
     138    @ivar _extraCertChain: Accumulated C{list} of all extra certificates added
     139        by L{add_extra_chain_cert}.
    127140    """
    128141    _options = 0
    129142
    class OpenSSLOptions(unittest.TestCase): 
    290303
    291304    def test_constructorSetsExtraChain(self):
    292305        """
    293         Setting C{extraCertChain} sets both if C{certificate} and C{privateKey}
    294         are set too.
     306        Setting C{extraCertChain} works if C{certificate} and C{privateKey} are
     307        set along with it.
    295308        """
    296309        opts = sslverify.OpenSSLCertificateOptions(
    297310            privateKey=self.sKey,
    class OpenSSLOptions(unittest.TestCase): 
    329342
    330343    def test_extraChainFilesAreAddedIfSupplied(self):
    331344        """
    332         C{extraCertChain} is respected when creating contexts.
     345        If C{extraCertChain} is set and all prerequisites are met, the
     346        specified chain certificates are added to C{Context}s that get
     347        created.
    333348        """
    334349        opts = sslverify.OpenSSLCertificateOptions(
    335350            privateKey=self.sKey,