- alpn_ctx.data = NULL;
- if (alpn_in)
- {
- unsigned short len;
- alpn_ctx.data = next_protos_parse(&len, alpn_in);
- if (alpn_ctx.data == NULL)
- goto end;
- alpn_ctx.len = len;
- }
-#endif
-
- if (crl_file)
- {
- X509_CRL *crl;
- crl = load_crl(crl_file, crl_format);
- if (!crl)
- {
- BIO_puts(bio_err, "Error loading CRL\n");
- ERR_print_errors(bio_err);
- goto end;
- }
- crls = sk_X509_CRL_new_null();
- if (!crls || !sk_X509_CRL_push(crls, crl))
- {
- BIO_puts(bio_err, "Error adding CRL\n");
- ERR_print_errors(bio_err);
- X509_CRL_free(crl);
- goto end;
- }
- }
-
-
- if (s_dcert_file)
- {
-
- if (s_dkey_file == NULL)
- s_dkey_file = s_dcert_file;
-
- s_dkey = load_key(bio_err, s_dkey_file, s_dkey_format,
- 0, dpass, e,
- "second certificate private key file");
- if (!s_dkey)
- {
- ERR_print_errors(bio_err);
- goto end;
- }
-
- s_dcert = load_cert(bio_err,s_dcert_file,s_dcert_format,
- NULL, e, "second server certificate file");
-
- if (!s_dcert)
- {
- ERR_print_errors(bio_err);
- goto end;
- }
- if (s_dchain_file)
- {
- s_dchain = load_certs(bio_err, s_dchain_file,FORMAT_PEM,
- NULL, e, "second server certificate chain");
- if (!s_dchain)
- goto end;
- }
-
- }
-
- if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
- && !RAND_status())
- {
- BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
- }
- if (inrand != NULL)
- BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
- app_RAND_load_files(inrand));
-
- if (bio_s_out == NULL)
- {
- if (s_quiet && !s_debug)
- {
- bio_s_out=BIO_new(BIO_s_null());
- if (s_msg && !bio_s_msg)
- bio_s_msg=BIO_new_fp(stdout,BIO_NOCLOSE);
- }
- else
- {
- if (bio_s_out == NULL)
- bio_s_out=BIO_new_fp(stdout,BIO_NOCLOSE);
- }
- }
-
-#if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
- if (nocert)
-#endif
- {
- s_cert_file=NULL;
- s_key_file=NULL;
- s_dcert_file=NULL;
- s_dkey_file=NULL;
-#ifndef OPENSSL_NO_TLSEXT
- s_cert_file2=NULL;
- s_key_file2=NULL;
-#endif
- }
-
- ctx=SSL_CTX_new(meth);
- if (ctx == NULL)
- {
- ERR_print_errors(bio_err);
- goto end;
- }
- if (session_id_prefix)
- {
- 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");
- ERR_print_errors(bio_err);
- goto end;
- }
- BIO_printf(bio_err,"id_prefix '%s' set.\n", session_id_prefix);
- }
- SSL_CTX_set_quiet_shutdown(ctx,1);
- if (hack) SSL_CTX_set_options(ctx,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
- if (exc) ssl_ctx_set_excert(ctx, exc);
- /* DTLS: partial reads end up discarding unread UDP bytes :-(
- * Setting read ahead solves this problem.
- */
- if (socket_type == SOCK_DGRAM) SSL_CTX_set_read_ahead(ctx, 1);
-
- if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
- if (no_cache)
- SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
- else if (ext_cache)
- init_session_cache_ctx(ctx);
- else
- SSL_CTX_sess_set_cache_size(ctx,128);
-
- if (srtp_profiles != NULL)
- SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles);
-
-#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; */
- }
- if (vpm)
- SSL_CTX_set1_param(ctx, vpm);
-
- ssl_ctx_add_crls(ctx, crls, 0);
- if (!args_ssl_call(ctx, bio_err, cctx, ssl_args, no_ecdhe, no_jpake))
- goto end;
-
- if (!ssl_load_stores(ctx, vfyCApath, vfyCAfile, chCApath, chCAfile,
- crls, crl_download))
- {
- BIO_printf(bio_err, "Error loading store locations\n");
- ERR_print_errors(bio_err);
- goto end;
- }
+ alpn_ctx.data = NULL;
+ if (alpn_in) {
+ unsigned short len;
+ alpn_ctx.data = next_protos_parse(&len, alpn_in);
+ if (alpn_ctx.data == NULL)
+ goto end;
+ alpn_ctx.len = len;
+ }
+#endif
+
+ if (crl_file) {
+ X509_CRL *crl;
+ crl = load_crl(crl_file, crl_format);
+ if (!crl) {
+ BIO_puts(bio_err, "Error loading CRL\n");
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+ crls = sk_X509_CRL_new_null();
+ if (!crls || !sk_X509_CRL_push(crls, crl)) {
+ BIO_puts(bio_err, "Error adding CRL\n");
+ ERR_print_errors(bio_err);
+ X509_CRL_free(crl);
+ goto end;
+ }
+ }
+
+ if (s_dcert_file) {
+
+ if (s_dkey_file == NULL)
+ s_dkey_file = s_dcert_file;
+
+ s_dkey = load_key(bio_err, s_dkey_file, s_dkey_format,
+ 0, dpass, e, "second certificate private key file");
+ if (!s_dkey) {
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+
+ s_dcert = load_cert(bio_err, s_dcert_file, s_dcert_format,
+ NULL, e, "second server certificate file");
+
+ if (!s_dcert) {
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+ if (s_dchain_file) {
+ s_dchain = load_certs(bio_err, s_dchain_file, FORMAT_PEM,
+ NULL, e, "second server certificate chain");
+ if (!s_dchain)
+ goto end;
+ }