How to determine if an incoming SSL connection is waiting?

I want to use 1 port for both unencrypted TCP and SSL.

The goal is to make 1 port of entry to the machine. This means that mux has all the protocols and transports in the port. For example, I look at the first 4 bytes of a stream. If it starts with "GET", "POST", "HEAD", etc. I know this is the HTTP protocol, so I am transferring a connection to an HTTP server. If it is "HELO" or "EHLO", I know to pass it to the SMTP server.

The problem is what I'm looking for if this is an SSL connection (to pass it OpenSSL)?

+4
source share
1 answer

SSL 2 will have 8x yz (hex) as the first two bytes (x yz can be anything, for example 8F 13), and SSL 3 and later - 16 03 hex as the first two bytes.

Update: as indicated in the comments, some protocols require the server to send something first (FTP and POP3, to name a few, and SMTP is mentioned in the comment), so your approach will only work for a limited number of protocols.

+4
source

All Articles