Beispiel #1
0
    def start(self,
              port: int,
              tls_key_filepath: Path = None,
              tls_certificate_filepath: Path = None,
              dry_run: bool = False):
        if dry_run:
            return

        if tls_key_filepath and tls_certificate_filepath:
            self.log.info("Starting HTTPS Control...")
            # HTTPS endpoint
            hx_deployer = HendrixDeployTLS(
                action="start",
                key=str(tls_key_filepath.absolute()),
                cert=str(tls_certificate_filepath.absolute()),
                options={
                    "wsgi": self._transport,
                    "https_port": port,
                    "resources": get_static_resources()
                })
        else:
            # HTTP endpoint
            # TODO #845: Make non-blocking web control startup
            self.log.info("Starting HTTP Control...")
            hx_deployer = HendrixDeploy(action="start",
                                        options={
                                            "wsgi": self._transport,
                                            "http_port": port,
                                            "resources":
                                            get_static_resources()
                                        })

        hx_deployer.run()  # <--- Blocking Call to Reactor
Beispiel #2
0
from nkms.crypto.api import generate_self_signed_certificate

DB_NAME = "non-mining-proxy-node"

_URSULA = Ursula(dht_port=3501,
                 rest_port=3601,
                 ip_address="localhost",
                 db_name=DB_NAME)
_URSULA.dht_listen()

CURVE = ec.SECP256R1
cert, private_key = generate_self_signed_certificate(
    _URSULA.stamp.fingerprint().decode(), CURVE)

deployer = HendrixDeployTLS("start", {
    "wsgi": _URSULA.rest_app,
    "https_port": _URSULA.rest_port
},
                            key=private_key,
                            cert=X509.from_cryptography(cert),
                            context_factory=ExistingKeyTLSContextFactory,
                            context_factory_kwargs={
                                "curve_name": "prime256v1",
                                "sslmethod": TLSv1_2_METHOD
                            })

try:
    deployer.run()
finally:
    os.remove(DB_NAME)
Beispiel #3
0
import sys

from hendrix.deploy.tls import HendrixDeployTLS
from hendrix.experience import hey_joe

sys.path.append("../django_nyc_demo")
from hendrix_demo.wsgi import application as hendrix_demo_app

PORT = 8443

# EC variant
# deployer = HendrixDeployTLS("start",
#                                {"wsgi": hendrix_demo_app, "https_port": PORT},
#                                key="ec-key.pem",
#                                cert="ec-certificate.pem",
#                                context_factory=SpecifiedCurveContextFactory,
#                                context_factory_kwargs={"curve_name": "secp256k1"}
#                                )

# RSA variant
deployer = HendrixDeployTLS("start",
                            {"wsgi": hendrix_demo_app, "https_port": PORT},
                            key="rsa-privkey.pem",
                            cert="rsa-certificate.pem",
                            )

wss_service = hey_joe.WSSWebSocketService("127.0.0.1", 9443,
                                          allowedOrigins=["https://localhost:{}".format(PORT)])
deployer.add_tls_websocket_service(wss_service)
deployer.run()