vibora
vibora copied to clipboard
HTTPS?
Is there a way to get HTTPS without going through Nginx or Apache?
I tried wrapping the socket like this:
srv_sock = socket()
srv_sock.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
srv_sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
srv_sock.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
srv_sock.bind(('0.0.0.0', settings.WEB_PORT))
srv_sock = ssl.wrap_socket(
srv_sock,
server_side=True,
certfile=settings.CERT_FILE,
)
That works on Python's built in HTTPServer but it doesn't seem to work here.
what is your result in this try?
The browser says something like SSL headers too long.
On Tue, Jul 17, 2018, 8:48 AM Daniel Däschle [email protected] wrote:
what is your result in this try?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vibora-io/vibora/issues/151#issuecomment-405569862, or mute the thread https://github.com/notifications/unsubscribe-auth/AB8pvxfWa5efNZZvZ-qTkJbhnEN5MtSaks5uHd0sgaJpZM4VRz5v .
Can you send the full stack trace / error please?
The terminal running Vibora says:
AttributeError: 'vibora.protocol.cprotocol.Connection' object has no attribute 'route'
Exception ignored in: 'vibora.protocol.cprotocol.Connection.handle_upgrade'
The browser says: An error occurred during a connection to localhost:8000. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG
Am I not doing something right?
Is this error from vibora the whole stack trace? Please post everything you have please.
@agronick HTTPS is not supported yet, I'll add this into v0.1, thanks for reporting it
I wonder what the author's recommendation would be for running the server directly in production. I'm planning on migrating a large application from Sanic to Vibora. But I deploy the app with gunicorn workers behind an nginx reverse proxy.
Just start you python file. The framework has a efficient integrated server. There is no gunicorn or something similar needed.
I made such try:
import socket
import ssl
def openSslSock(host,port,cert,key):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
sock.bind((host,port))
sock.listen(5)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(cert,key)
ssock = context.wrap_socket(sock,server_side=True)
return ssock
and:
ssock = None
if config.website.get('ssl',False):
ssock = openSslSock(
config.website.host,
config.website.port,
config.website.ssl.crtfile,
config.website.ssl.keyfile)
app.run(debug=config.debug,
host=config.website.host,
port=config.website.port,
sock=ssock)
But it is failed to work, the error mesages are:
Traceback (most recent call last): File "vibora/protocol/cprotocol.pyx", line 298, in vibora.protocol.cprotocol.Connection.data_received File "vibora/parsers/parser.pyx", line 145, in vibora.parsers.parser.HttpParser.feed_data vibora.parsers.errors.HttpParserInvalidMethodError: invalid HTTP method Traceback (most recent call last): File "vibora/protocol/cprotocol.pyx", line 298, in vibora.protocol.cprotocol.Connection.data_received File "vibora/parsers/parser.pyx", line 145, in vibora.parsers.parser.HttpParser.feed_data vibora.parsers.errors.HttpParserInvalidMethodError: invalid HTTP method Traceback (most recent call last): File "vibora/protocol/cprotocol.pyx", line 298, in vibora.protocol.cprotocol.Connection.data_received File "vibora/parsers/parser.pyx", line 145, in vibora.parsers.parser.HttpParser.feed_data vibora.parsers.errors.HttpParserInvalidMethodError: invalid HTTP method