#๐Ÿ”’ SSL Handling my CONNECT Requests For Me (Issue)

4 messages ยท Page 1 of 1 (latest)

austere plover
#

Hi there, I really need help preventing or finding an alternative for SSL handling my TLS handshakes or any CONNECT requests. Here is my code:

BUFFER_SIZE = 61440

import socket
import threading
import ssl
import re

def wrapSSLSocket(socket):
    return ssl.wrap_socket(
        socket, 
        certfile='credentials/serverCert.pem', 
        keyfile='credentials/serverKey.pem', 
        server_side=True,
        ssl_version=ssl.PROTOCOL_TLSv1_2
    )

def Host(http_request):
    host_pattern = r'Host:\s*([^\s:]+)'
    match = re.search(host_pattern, http_request)
    if match:
        return match.group(1)
    
def isChunked(data):
    return True if "Transfer-Encoding: chunked" in data else False

def handleSocket(sock: socket.socket):
    try:
        sock = wrapSSLSocket(sock)
        while True:
            data = sock.recv(BUFFER_SIZE).decode()
            #CONNECT REQUESTS NEVER REACH handleSocket at all.
    finally:
        sock.close()
    
def HTTPS():
    try:
        server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_socket.bind(("0.0.0.0", 443))
        server_socket.listen(10)
        while True:
            client_socket, _ = server_socket.accept()
            threading.Thread(target=handleSocket, args=(client_socket,)).start()
    except Exception:
        print("Couldn't start HTTPS server.")
    finally:
        server_socket.close()```
noble furnaceBOT
#

@austere plover

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

noble furnaceBOT
#

@austere plover

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.