[openssl-users] HTTP / HTTPS on same port

James james.arivazhagan at gmail.com
Sat Apr 4 03:40:01 UTC 2015


Hi,
I suggested one such implementation in mongoose opensource web server
You can check it in .

https://groups.google.com/forum/#!msg/mongoose-users/IAzYHF0do-I/INc_VmLAe6gJ

This is the function I added
let me know if it is useful.


static int CheckSSL(int nSocket)
{
  /* taken from s23_svr.c int ssl23_get_client_hello(SSL *s) of openssl */
  char szData [12] ;
  int nRet = 0 ;
  int n;
  memset ( szData, 0, sizeof(szData));
  n = recv ( nSocket, szData, 11, MSG_PEEK ) ;

  if (n > 2)
  {
     if((szData[0] & 0x80) && (szData[2] == 1)) // SSL2_MT_CLIENT_HELLO
     {
       // SSLv2
       nRet = 1;
     }
     else if(n > 9)
     {
        if ((szData[0] == 22 ) &&              // SSL3_RT_HANDSHAKE
           (szData[1] == 0x03) &&              // SSL3_VERSION_MAJOR
           (szData[5] == 1) &&                 // SSL3_MT_CLIENT_HELLO
           ((szData[3] == 0 && szData[4] < 5)
            || (szData[9] == szData[1])))
        {
          // SSLv3
          nRet = 1;
        }
     }
  }
  return nRet;
}


On Sat, Apr 4, 2015 at 5:10 AM, James Cloos <cloos at jhcloos.com> wrote:

> >>>>> "JR" == Joris Van Remoortere <joris at mesosphere.io> writes:
>
> JR> I would like to ask your opinion and advice on accepting HTTP / HTTPS
> JR> connections on the same port.
>
> IPP support both w/ and w/o tls on port 631.
>
> Cups handles it like this:
>
>   http://www.pwg.org/archives/ipp/2014/017906.html
>
> -JimC
> --
> James Cloos <cloos at jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6
> _______________________________________________
> openssl-users mailing list
> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20150404/e1147ec5/attachment-0001.html>


More information about the openssl-users mailing list