/*
* Copyright (C) 2004-2012 Free Software Foundation, Inc.
* Copyright (C) 2001,2002 Paul Sheer
* Copyright (C) 2016-2018 Red Hat, Inc.
* Portions Copyright (C) 2002,2003 Nikos Mavrogiannopoulos
*
* This file is part of GnuTLS.
*
* GnuTLS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GnuTLS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/* This server is heavily modified for GnuTLS by Nikos Mavrogiannopoulos
* (which means it is quite unreadable)
*/
#include
#include "common.h"
#include "serv-args.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/* Gnulib portability files. */
#include "read-file.h"
#include "minmax.h"
#include "sockets.h"
#include "udp-serv.h"
/* konqueror cannot handle sending the page in multiple
* pieces.
*/
/* global stuff */
static int generate = 0;
static int http = 0;
static int x509ctype;
static int debug = 0;
unsigned int verbose = 1;
static int nodb;
static int noticket;
static int earlydata;
int require_cert;
int disable_client_cert;
const char *psk_passwd = NULL;
const char *srp_passwd = NULL;
const char *srp_passwd_conf = NULL;
const char **x509_keyfile = NULL;
const char **x509_certfile = NULL;
unsigned x509_certfile_size = 0;
unsigned x509_keyfile_size = 0;
const char *x509_cafile = NULL;
const char *dh_params_file = NULL;
const char *x509_crlfile = NULL;
const char *priorities = NULL;
const char **ocsp_responses = NULL;
unsigned ocsp_responses_size = 0;
const char *sni_hostname = NULL;
int sni_hostname_fatal = 0;
const char **alpn_protos = NULL;
unsigned alpn_protos_size = 0;
gnutls_datum_t session_ticket_key;
gnutls_anti_replay_t anti_replay;
static void tcp_server(const char *name, int port);
/* end of globals */
/* This is a sample TCP echo server.
* This will behave as an http server if any argument in the
* command line is present
*/
#define SMALL_READ_TEST (2147483647)
#define GERR(ret) fprintf(stdout, "Error: %s\n", safe_strerror(ret))
#define HTTP_END "