1

i have a twisted server with TLS:

from twisted.web.server import Site
from twisted.web.static import Data
from twisted.internet import reactor, ssl

port = 88888
root = Data("", "text/plain")
site = Site(root)
reactor.listenSSL(port, site, ssl.DefaultOpenSSLContextFactory(
                              '/etc/apache2/ssl/wc.key',
                              '/etc/apache2/ssl/wc.crt'))

I have 2 domains, so i need to add another ssl certificate for another domain. I found similar question here Twisted listenSSL virtualhosts but i did not understand how to modify my code for 2 certifcates. Can anybody show me how to use 2 certifactes in twisted?

P.S. Thank you, i did it in this way:

from twisted.web.server import Site
from twisted.web.static import Data
from twisted.internet import reactor, ssl
from txsni.snimap import SNIMap
from txsni.maputils import Cache
from txsni.snimap import HostDirectoryMap
from twisted.python.filepath import FilePath
from os.path import expanduser

root = Data("", "text/plain")
site = Site(root)
contextFactory = SNIMap(
    Cache(HostDirectoryMap(FilePath(expanduser('/home/user/certificates_dir'))))
)
reactor.listenSSL(config.ws_port, site, contextFactory)
Community
  • 1
  • 1
kalombo
  • 861
  • 1
  • 9
  • 31

1 Answers1

2

You should check out TxSNI. It should do what you want with a very straightforward arrangement of multiple certificates in a directory.

Glyph
  • 31,152
  • 11
  • 87
  • 129