def creatorForNetloc(self, hostname, port):
     hostname = hostname.decode("ascii")
     certificate_options = OpenSSLCertificateOptions(
         trustRoot=None,
         acceptableProtocols=None,
     )
     return DisabledVerificationClientTLSOptions(
         hostname, certificate_options.getContext())
Exemple #2
0
def optionsForClientTLS(hostname, trustRoot=None, clientCertificate=None, **kw):
    """
    Reimplemented from twisted.internet.ssl to allow extra parameters to be passed correctly.

    @return: A client connection creator.
    @rtype: L{IOpenSSLClientConnectionCreator}
    """
    extraCertificateOptions = kw.pop('extraCertificateOptions', None) or {}
    if kw:
        raise TypeError(
            "optionsForClientTLS() got an unexpected keyword argument"
            " '{arg}'".format(
                arg=kw.popitem()[0]
            )
        )
    if not isinstance(hostname, unicode):
        raise TypeError(
            "optionsForClientTLS requires text for host names, not "
            + hostname.__class__.__name__
        )
    if clientCertificate:
        extraCertificateOptions.update(
            privateKey=clientCertificate.privateKey.original,
            certificate=clientCertificate.original
        )

    # Only pass the trustRoot if it is not None to avoid mutually exclusive param issues.
    if trustRoot:
        certificateOptions = OpenSSLCertificateOptions(
            trustRoot=trustRoot,
            **extraCertificateOptions
        )
    else:
        certificateOptions = OpenSSLCertificateOptions(**extraCertificateOptions)

    return SSLClientConnectionCreator(hostname, certificateOptions.getContext())
Exemple #3
0
 def creatorForNetloc(self, hostname, port):
     certificateOptions = OpenSSLCertificateOptions()
     return ClientTLSOptions(hostname, certificateOptions.getContext())
 def creatorForNetloc(self, hostname, port):
     certificateOptions = OpenSSLCertificateOptions()
     return ClientTLSOptions(hostname, certificateOptions.getContext())