# -*- coding: UTF-8 -*-
import os
from OpenSSL import SSL
from zephir.config import ROOT_DIR, cert_file, key_file

#################################################
## Factory permettant de créer un contexte SSL ##
#################################################
class ServerContextFactory:

    def getContext(self):
        """Create an SSL context.
        This is a sample implementation that loads a certificate from a file 
        called 'server.pem'."""
        ctx = SSL.Context(SSL.TLS_METHOD)
        ctx.set_options(SSL.OP_NO_TLSv1_1 | SSL.OP_NO_TLSv1)
        ctx.use_certificate_chain_file(cert_file)
        ctx.use_privatekey_file(key_file)
        return ctx
