diff -cr stunnel-4.15/src/protocol.c stunnel-4.15-pgsql-patch/src/protocol.c *** stunnel-4.15/src/protocol.c Wed Mar 1 15:43:58 2006 --- stunnel-4.15-pgsql-patch/src/protocol.c Fri Jun 23 22:56:18 2006 *************** *** 45,50 **** --- 45,51 ---- static void pop3_server(CLI *); static void nntp_client(CLI *); static void connect_client(CLI *); + static void pgsql_client(CLI *); void negotiate(CLI *c) { if(!c->opt->protocol) *************** *** 64,69 **** --- 65,72 ---- nntp_client(c); else if(!strcmp(c->opt->protocol, "connect")) connect_client(c); + else if(!strcmp(c->opt->protocol, "pgsql")) + pgsql_client(c); else { s_log(LOG_ERR, "Protocol %s not supported in client mode", c->opt->protocol); *************** *** 271,274 **** --- 274,290 ---- } while(line[0]); } + static void pgsql_client(CLI *c) { + u8 buffer[1]; + u8 request[8] = {0x00, 0x00, 0x00, 0x08, 0x04, 0xd2, 0x16, 0x2f}; + + write_blocking(c, c->remote_fd.fd, request, 8); + read_blocking(c, c->remote_fd.fd, buffer, 1); + + if(buffer[0] != 'S') { + s_log(LOG_ERR, "Server does not support SSL"); + longjmp(c->err, 1); + } + } + /* End of protocol.c */