do_server(port,&accept_socket,sv_body);
do_server(port,&accept_socket,sv_body, context);
int MAIN(argc, argv)int argc;char *argv[];	{	short port=PORT;	char *CApath=NULL,*CAfile=NULL;	int badop=0,bugs=0;	int ret=1;	int off=0;	int no_tmp_rsa=0,nocert=0;	int state=0;	SSL_METHOD *meth=NULL;#ifndef NO_DH	DH *dh=NULL;#endif#if !defined(NO_SSL2) && !defined(NO_SSL3)	meth=SSLv23_server_method();#elif !defined(NO_SSL3)	meth=SSLv3_server_method();#elif !defined(NO_SSL2)	meth=SSLv2_server_method();#endif	local_argc=argc;	local_argv=argv;	apps_startup();	s_quiet=0;	s_debug=0;	if (bio_err == NULL)		bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);	verify_depth=0;#ifdef FIONBIO	s_nbio=0;#endif	s_nbio_test=0;	argc--;	argv++;	while (argc >= 1)		{		if	((strcmp(*argv,"-port") == 0) ||			 (strcmp(*argv,"-accept") == 0))			{			if (--argc < 1) goto bad;			if (!extract_port(*(++argv),&port))				goto bad;			}		else if	(strcmp(*argv,"-verify") == 0)			{			s_server_verify=SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE;			if (--argc < 1) goto bad;			verify_depth=atoi(*(++argv));			BIO_printf(bio_err,"verify depth is %d\n",verify_depth);			}		else if	(strcmp(*argv,"-Verify") == 0)			{			s_server_verify=SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT|				SSL_VERIFY_CLIENT_ONCE;			if (--argc < 1) goto bad;			verify_depth=atoi(*(++argv));			BIO_printf(bio_err,"verify depth is %d, must return a certificate\n",verify_depth);			}		else if	(strcmp(*argv,"-cert") == 0)			{			if (--argc < 1) goto bad;			s_cert_file= *(++argv);			}		else if	(strcmp(*argv,"-key") == 0)			{			if (--argc < 1) goto bad;			s_key_file= *(++argv);			}		else if	(strcmp(*argv,"-dcert") == 0)			{			if (--argc < 1) goto bad;			s_dcert_file= *(++argv);			}		else if	(strcmp(*argv,"-dkey") == 0)			{			if (--argc < 1) goto bad;			s_dkey_file= *(++argv);			}		else if (strcmp(*argv,"-nocert") == 0)			{			nocert=1;			}		else if	(strcmp(*argv,"-CApath") == 0)			{			if (--argc < 1) goto bad;			CApath= *(++argv);			}		else if	(strcmp(*argv,"-cipher") == 0)			{			if (--argc < 1) goto bad;			cipher= *(++argv);			}		else if	(strcmp(*argv,"-CAfile") == 0)			{			if (--argc < 1) goto bad;			CAfile= *(++argv);			}#ifdef FIONBIO			else if	(strcmp(*argv,"-nbio") == 0)			{ s_nbio=1; }#endif		else if	(strcmp(*argv,"-nbio_test") == 0)			{#ifdef FIONBIO				s_nbio=1;#endif			s_nbio_test=1;			}		else if	(strcmp(*argv,"-debug") == 0)			{ s_debug=1; }		else if	(strcmp(*argv,"-hack") == 0)			{ hack=1; }		else if	(strcmp(*argv,"-state") == 0)			{ state=1; }		else if	(strcmp(*argv,"-quiet") == 0)			{ s_quiet=1; }		else if	(strcmp(*argv,"-bugs") == 0)			{ bugs=1; }		else if	(strcmp(*argv,"-no_tmp_rsa") == 0)			{ no_tmp_rsa=1; }		else if	(strcmp(*argv,"-www") == 0)			{ www=1; }		else if	(strcmp(*argv,"-WWW") == 0)			{ www=2; }		else if	(strcmp(*argv,"-no_ssl2") == 0)			{ off|=SSL_OP_NO_SSLv2; }		else if	(strcmp(*argv,"-no_ssl3") == 0)			{ off|=SSL_OP_NO_SSLv3; }		else if	(strcmp(*argv,"-no_tls1") == 0)			{ off|=SSL_OP_NO_TLSv1; }#ifndef NO_SSL2		else if	(strcmp(*argv,"-ssl2") == 0)			{ meth=SSLv2_server_method(); }#endif#ifndef NO_SSL3		else if	(strcmp(*argv,"-ssl3") == 0)			{ meth=SSLv3_server_method(); }#endif#ifndef NO_TLS1		else if	(strcmp(*argv,"-tls1") == 0)			{ meth=TLSv1_server_method(); }#endif		else			{			BIO_printf(bio_err,"unknown option %s\n",*argv);			badop=1;			break;			}		argc--;		argv++;		}	if (badop)		{bad:		sv_usage();		goto end;		}	if (bio_s_out == NULL)		{		if (s_quiet && !s_debug)			{			bio_s_out=BIO_new(BIO_s_null());			}		else			{			if (bio_s_out == NULL)				bio_s_out=BIO_new_fp(stdout,BIO_NOCLOSE);			}		}#if !defined(NO_RSA) || !defined(NO_DSA)	if (nocert)#endif		{		s_cert_file=NULL;		s_key_file=NULL;		s_dcert_file=NULL;		s_dkey_file=NULL;		}	SSL_load_error_strings();	SSLeay_add_ssl_algorithms();	ctx=SSL_CTX_new(meth);	if (ctx == NULL)		{		ERR_print_errors(bio_err);		goto end;		}	SSL_CTX_set_quiet_shutdown(ctx,1);	if (bugs) SSL_CTX_set_options(ctx,SSL_OP_ALL);	if (hack) SSL_CTX_set_options(ctx,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);	SSL_CTX_set_options(ctx,off);	if (hack) SSL_CTX_set_options(ctx,SSL_OP_NON_EXPORT_FIRST);	if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);	SSL_CTX_sess_set_cache_size(ctx,128);#if 0	if (cipher == NULL) cipher=getenv("SSL_CIPHER");#endif#if 0	if (s_cert_file == NULL)		{		BIO_printf(bio_err,"You must specify a certificate file for the server to use\n");		goto end;		}#endif	if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) ||		(!SSL_CTX_set_default_verify_paths(ctx)))		{		/* BIO_printf(bio_err,"X509_load_verify_locations\n"); */		ERR_print_errors(bio_err);		/* goto end; */		}#ifndef NO_DH	/* EAY EAY EAY evil hack */	dh=load_dh_param();	if (dh != NULL)		{		BIO_printf(bio_s_out,"Setting temp DH parameters\n");		}	else		{		BIO_printf(bio_s_out,"Using default temp DH parameters\n");		dh=get_dh512();		}	BIO_flush(bio_s_out);	SSL_CTX_set_tmp_dh(ctx,dh);	DH_free(dh);#endif		if (!set_cert_stuff(ctx,s_cert_file,s_key_file))		goto end;	if (s_dcert_file != NULL)		{		if (!set_cert_stuff(ctx,s_dcert_file,s_dkey_file))			goto end;		}#if 1	SSL_CTX_set_tmp_rsa_callback(ctx,tmp_rsa_cb);#else	if (!no_tmp_rsa && SSL_CTX_need_tmp_RSA(ctx))		{		RSA *rsa;		BIO_printf(bio_s_out,"Generating temp (512 bit) RSA key...");		BIO_flush(bio_s_out);		rsa=RSA_generate_key(512,RSA_F4,NULL);		if (!SSL_CTX_set_tmp_rsa(ctx,rsa))			{			ERR_print_errors(bio_err);			goto end;			}		RSA_free(rsa);		BIO_printf(bio_s_out,"\n");		}#endif	if (cipher != NULL)		SSL_CTX_set_cipher_list(ctx,cipher);	SSL_CTX_set_verify(ctx,s_server_verify,verify_callback);	SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));	BIO_printf(bio_s_out,"ACCEPT\n");	if (www)		do_server(port,&accept_socket,www_body);	else		do_server(port,&accept_socket,sv_body);	print_stats(bio_s_out,ctx);	ret=0;end:	if (ctx != NULL) SSL_CTX_free(ctx);	if (bio_s_out != NULL)		{		BIO_free(bio_s_out);		bio_s_out=NULL;		}	EXIT(ret);	}