def _parseSSL(factory, port, privateKey='server.pem', certKey=None, sslmethod=None, interface='', backlog=50, extraCertChain=None, dhParameters=None):
 from twisted.internet import ssl
 if (certKey is None):
  certKey = privateKey
 kw = {}
 if (sslmethod is not None):
  kw['method'] = getattr(ssl.SSL, sslmethod)
 certPEM = FilePath(certKey).getContent()
 keyPEM = FilePath(privateKey).getContent()
 privateCertificate = ssl.PrivateCertificate.loadPEM((certPEM + keyPEM))
 if (extraCertChain is not None):
  matches = re.findall('(-----BEGIN CERTIFICATE-----\\n.+?\\n-----END CERTIFICATE-----)', nativeString(FilePath(extraCertChain).getContent()), flags=re.DOTALL)
  chainCertificates = [ssl.Certificate.loadPEM(chainCertPEM).original for chainCertPEM in matches]
  if (not chainCertificates):
   raise ValueError(("Specified chain file '%s' doesn't contain any valid certificates in PEM format." % (extraCertChain,)))
 else:
  chainCertificates = None
 if (dhParameters is not None):
  dhParameters = ssl.DiffieHellmanParameters.fromFile(FilePath(dhParameters))
 cf = ssl.CertificateOptions(privateKey=privateCertificate.privateKey.original, certificate=privateCertificate.original, extraCertChain=chainCertificates, dhParameters=dhParameters, **kw)
 return ((int(port), factory, cf), {'interface': interface, 'backlog': int(backlog)})

def _parseSSL ( factory , port , privateKey = 'server.pem' , certKey = None , sslmethod = None , interface = '' , backlog = 50 , extraCertChain = None , dhParameters = None ) : from twisted . internet import ssl if ( certKey is None ) : certKey = privateKey kw = { } if ( sslmethod is not None ) : kw [ 'method' ] = getattr ( ssl . SSL , sslmethod ) certPEM = FilePath ( certKey ) . getContent ( ) keyPEM = FilePath ( privateKey ) . getContent ( ) privateCertificate = ssl . PrivateCertificate . loadPEM ( ( certPEM + keyPEM ) ) if ( extraCertChain is not None ) : matches = re . findall ( '(-----BEGIN CERTIFICATE-----\\n.+?\\n-----END CERTIFICATE-----)' , nativeString ( FilePath ( extraCertChain ) . getContent ( ) ) , flags = re . DOTALL ) chainCertificates = [ ssl . Certificate . loadPEM ( chainCertPEM ) . original for chainCertPEM in matches ] if ( not chainCertificates ) : raise ValueError ( ( "Specified chain file '%s' doesn't contain any valid certificates in PEM format." % ( extraCertChain , ) ) ) else : chainCertificates = None if ( dhParameters is not None ) : dhParameters = ssl . DiffieHellmanParameters . fromFile ( FilePath ( dhParameters ) ) cf = ssl . CertificateOptions ( privateKey = privateCertificate . privateKey . original , certificate = privateCertificate . original , extraCertChain = chainCertificates , dhParameters = dhParameters , ** kw ) return ( ( int ( port ) , factory , cf ) , { 'interface' : interface , 'backlog' : int ( backlog ) } )
internal parser function for l{_parseserver} to convert the string arguments for an ssl stream endpoint into the structured arguments .