Remove redundant OPENSSL_NO_DEPRECATED suppression
[openssl.git] / apps / s_server.c
index 239597e2a504e9124a0314ac82ab24115a41b20f..1e407696e7f4edc3e48d4da56c362be72e4cdbd7 100644 (file)
  * OTHERWISE.
  */
 
-/* Until the key-gen callbacks are modified to use newer prototypes, we allow
- * deprecated functions for openssl-internal code */
-#ifdef OPENSSL_NO_DEPRECATED
-#undef OPENSSL_NO_DEPRECATED
-#endif
 
 #include <assert.h>
 #include <ctype.h>
@@ -197,10 +192,6 @@ typedef unsigned int u_int;
 #undef FIONBIO
 #endif
 
-#if defined(OPENSSL_SYS_BEOS_R5)
-#include <fcntl.h>
-#endif
-
 #ifndef OPENSSL_NO_RSA
 static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength);
 #endif
@@ -508,8 +499,9 @@ static void sv_usage(void)
        BIO_printf(bio_err," -srpvfile file      - The verifier file for SRP\n");
        BIO_printf(bio_err," -srpuserseed string - A seed string for a default user salt.\n");
 #endif
-       BIO_printf(bio_err," -ssl2         - Just talk SSLv2\n");
+#ifndef OPENSSL_NO_SSL3_METHOD
        BIO_printf(bio_err," -ssl3         - Just talk SSLv3\n");
+#endif
        BIO_printf(bio_err," -tls1_2       - Just talk TLSv1.2\n");
        BIO_printf(bio_err," -tls1_1       - Just talk TLSv1.1\n");
        BIO_printf(bio_err," -tls1         - Just talk TLSv1\n");
@@ -518,7 +510,6 @@ static void sv_usage(void)
        BIO_printf(bio_err," -timeout      - Enable timeouts\n");
        BIO_printf(bio_err," -mtu          - Set link layer MTU\n");
        BIO_printf(bio_err," -chain        - Read a certificate chain\n");
-       BIO_printf(bio_err," -no_ssl2      - Just disable SSLv2\n");
        BIO_printf(bio_err," -no_ssl3      - Just disable SSLv3\n");
        BIO_printf(bio_err," -no_tls1      - Just disable TLSv1\n");
        BIO_printf(bio_err," -no_tls1_1    - Just disable TLSv1.1\n");
@@ -740,7 +731,7 @@ static int MS_CALLBACK ssl_servername_cb(SSL *s, int *ad, void *arg)
        
        if (servername)
                {
-               if (strcmp(servername,p->servername)) 
+               if (strcasecmp(servername,p->servername)) 
                        return p->extension_error;
                if (ctx2)
                        {
@@ -1404,11 +1395,7 @@ int MAIN(int argc, char *argv[])
                        { www=2; }
                else if (strcmp(*argv,"-HTTP") == 0)
                        { www=3; }
-#ifndef OPENSSL_NO_SSL2
-               else if (strcmp(*argv,"-ssl2") == 0)
-                       { meth=SSLv2_server_method(); }
-#endif
-#ifndef OPENSSL_NO_SSL3
+#ifndef OPENSSL_NO_SSL3_METHOD
                else if (strcmp(*argv,"-ssl3") == 0)
                        { meth=SSLv3_server_method(); }
 #endif
@@ -1532,6 +1519,14 @@ bad:
                sv_usage();
                goto end;
                }
+#ifndef OPENSSL_NO_DTLS1
+       if (www && socket_type == SOCK_DGRAM)
+               {
+               BIO_printf(bio_err,
+                               "Can't use -HTTP, -www or -WWW with DTLS\n");
+               goto end;
+               }
+#endif
 
        if (unix_path && (socket_type != SOCK_STREAM))
                {
@@ -1755,9 +1750,6 @@ bad:
                if(strlen(session_id_prefix) >= 32)
                        BIO_printf(bio_err,
 "warning: id_prefix is too long, only one new session will be possible\n");
-               else if(strlen(session_id_prefix) >= 16)
-                       BIO_printf(bio_err,
-"warning: id_prefix is too long if you use SSLv2\n");
                if(!SSL_CTX_set_generate_session_id(ctx, generate_session_id))
                        {
                        BIO_printf(bio_err,"error setting 'id_prefix'\n");
@@ -1842,9 +1834,6 @@ bad:
                        if(strlen(session_id_prefix) >= 32)
                                BIO_printf(bio_err,
                                        "warning: id_prefix is too long, only one new session will be possible\n");
-                       else if(strlen(session_id_prefix) >= 16)
-                               BIO_printf(bio_err,
-                                       "warning: id_prefix is too long if you use SSLv2\n");
                        if(!SSL_CTX_set_generate_session_id(ctx2, generate_session_id))
                                {
                                BIO_printf(bio_err,"error setting 'id_prefix'\n");
@@ -2216,7 +2205,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
        KSSL_CTX *kctx;
 #endif
        struct timeval timeout;
-#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS_R5)
+#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE)
        struct timeval tv;
 #else
        struct timeval *timeoutp;
@@ -2289,10 +2278,24 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
                        BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);
                        }
 
-               if (socket_mtu > 28)
+               if (socket_mtu)
                        {
+                       if(socket_mtu < DTLS_get_link_min_mtu(con))
+                               {
+                               BIO_printf(bio_err,"MTU too small. Must be at least %ld\n",
+                                       DTLS_get_link_min_mtu(con));
+                               ret = -1;
+                               BIO_free(sbio);
+                               goto err;
+                               }
                        SSL_set_options(con, SSL_OP_NO_QUERY_MTU);
-                       SSL_set_mtu(con, socket_mtu - 28);
+                       if(!DTLS_set_link_mtu(con, socket_mtu))
+                               {
+                               BIO_printf(bio_err, "Failed to set MTU\n");
+                               ret = -1;
+                               BIO_free(sbio);
+                               goto err;
+                               }
                        }
                else
                        /* want to do MTU discovery */
@@ -2356,7 +2359,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
                if (!read_from_sslcon)
                        {
                        FD_ZERO(&readfds);
-#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE) && !defined(OPENSSL_SYS_BEOS_R5)
+#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE)
                        openssl_fdset(fileno(stdin),&readfds);
 #endif
                        openssl_fdset(s,&readfds);
@@ -2378,17 +2381,6 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
                        if((i < 0) || (!i && !_kbhit() ) )continue;
                        if(_kbhit())
                                read_from_terminal = 1;
-#elif defined(OPENSSL_SYS_BEOS_R5)
-                       /* Under BeOS-R5 the situation is similar to DOS */
-                       tv.tv_sec = 1;
-                       tv.tv_usec = 0;
-                       (void)fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
-                       i=select(width,(void *)&readfds,NULL,NULL,&tv);
-                       if ((i < 0) || (!i && read(fileno(stdin), buf, 0) < 0))
-                               continue;
-                       if (read(fileno(stdin), buf, 0) >= 0)
-                               read_from_terminal = 1;
-                       (void)fcntl(fileno(stdin), F_SETFL, 0);
 #else
                        if ((SSL_version(con) == DTLS1_VERSION) &&
                                DTLSv1_get_timeout(con, &timeout))
@@ -2963,7 +2955,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
                                BIO_printf(bio_s_out,"read R BLOCK\n");
 #if defined(OPENSSL_SYS_NETWARE)
             delay(1000);
-#elif !defined(OPENSSL_SYS_MSDOS) && !defined(__DJGPP__)
+#elif !defined(OPENSSL_SYS_MSDOS)
                                sleep(1);
 #endif
                                continue;
@@ -3358,7 +3350,7 @@ static int rev_body(char *hostname, int s, int stype, unsigned char *context)
                                BIO_printf(bio_s_out,"read R BLOCK\n");
 #if defined(OPENSSL_SYS_NETWARE)
             delay(1000);
-#elif !defined(OPENSSL_SYS_MSDOS) && !defined(__DJGPP__)
+#elif !defined(OPENSSL_SYS_MSDOS)
                                sleep(1);
 #endif
                                continue;