@@ -400,7 +400,7 @@ static void sc_usage(void)
400
400
" 'prot' defines which one to assume. Currently,\n" );
401
401
BIO_printf (bio_err ,
402
402
" only \"smtp\", \"pop3\", \"imap\", \"ftp\", \"xmpp\"\n" );
403
- BIO_printf (bio_err , " \"telnet\" and \"ldap \" are supported.\n" );
403
+ BIO_printf (bio_err , " \"telnet\", \"ldap\" and \"postgres \" are supported.\n" );
404
404
BIO_printf (bio_err , " are supported.\n" );
405
405
BIO_printf (bio_err ," -xmpphost host - When used with \"-starttls xmpp\" specifies the virtual host.\n" );
406
406
#ifndef OPENSSL_NO_ENGINE
@@ -657,8 +657,9 @@ enum {
657
657
PROTO_IMAP ,
658
658
PROTO_FTP ,
659
659
PROTO_XMPP ,
660
- PROTO_TELNET ,
661
- PROTO_LDAP
660
+ PROTO_TELNET ,
661
+ PROTO_LDAP ,
662
+ PROTO_POSTGRES
662
663
};
663
664
664
665
int MAIN (int , char * * );
@@ -1105,6 +1106,8 @@ int MAIN(int argc, char **argv)
1105
1106
starttls_proto = PROTO_TELNET ;
1106
1107
else if (strcmp (* argv , "ldap" ) == 0 )
1107
1108
starttls_proto = PROTO_LDAP ;
1109
+ else if (strcmp (* argv , "postgres" ) == 0 )
1110
+ starttls_proto = PROTO_POSTGRES ;
1108
1111
else
1109
1112
goto bad ;
1110
1113
}
@@ -1790,6 +1793,23 @@ int MAIN(int argc, char **argv)
1790
1793
ASN1_TYPE_free (atyp );
1791
1794
}
1792
1795
1796
+ if (starttls_proto == PROTO_POSTGRES ) {
1797
+ static const unsigned char ssl_request [] = {
1798
+ /* Length SSLRequest */
1799
+ 0 , 0 , 0 , 8 , 4 , 210 , 22 , 47
1800
+ };
1801
+ int bytes ;
1802
+
1803
+ /* Send SSLRequest packet */
1804
+ BIO_write (sbio , ssl_request , 8 );
1805
+ (void )BIO_flush (sbio );
1806
+
1807
+ /* Reply will be a single S if SSL is enabled */
1808
+ bytes = BIO_read (sbio , sbuf , BUFSIZZ );
1809
+ if (bytes != 1 || sbuf [0 ] != 'S' )
1810
+ goto shut ;
1811
+ }
1812
+
1793
1813
for (;;) {
1794
1814
FD_ZERO (& readfds );
1795
1815
FD_ZERO (& writefds );
@@ -2179,6 +2199,7 @@ int MAIN(int argc, char **argv)
2179
2199
write_ssl = 1 ;
2180
2200
read_tty = 0 ;
2181
2201
}
2202
+ break ;
2182
2203
}
2183
2204
2184
2205
ret = 0 ;
0 commit comments