summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/usr.bin/openssl/s_time.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/src/usr.bin/openssl/s_time.c b/src/usr.bin/openssl/s_time.c
index ef96fd59a7..735e73f78c 100644
--- a/src/usr.bin/openssl/s_time.c
+++ b/src/usr.bin/openssl/s_time.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_time.c,v 1.26 2018/08/14 15:25:04 cheloha Exp $ */ 1/* $OpenBSD: s_time.c,v 1.27 2018/08/18 16:51:33 cheloha Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -90,7 +90,7 @@
90extern int verify_depth; 90extern int verify_depth;
91 91
92static void s_time_usage(void); 92static void s_time_usage(void);
93static SSL *doConnection(SSL * scon); 93static int doConnection(SSL *);
94static int benchmark(int); 94static int benchmark(int);
95 95
96static SSL_CTX *tm_ctx = NULL; 96static SSL_CTX *tm_ctx = NULL;
@@ -345,42 +345,28 @@ s_time_main(int argc, char **argv)
345/*********************************************************************** 345/***********************************************************************
346 * doConnection - make a connection 346 * doConnection - make a connection
347 * Args: 347 * Args:
348 * scon = earlier ssl connection for session id, or NULL 348 * scon = SSL connection
349 * Returns: 349 * Returns:
350 * SSL * = the connection pointer. 350 * 1 on success, 0 on error
351 */ 351 */
352static SSL * 352static int
353doConnection(SSL * scon) 353doConnection(SSL *scon)
354{ 354{
355 struct pollfd pfd[1]; 355 struct pollfd pfd[1];
356 SSL *serverCon;
357 BIO *conn; 356 BIO *conn;
358 long verify_error; 357 long verify_error;
359 int i; 358 int i;
360 359
361 if ((conn = BIO_new(BIO_s_connect())) == NULL) 360 if ((conn = BIO_new(BIO_s_connect())) == NULL)
362 return (NULL); 361 return 0;
363
364/* BIO_set_conn_port(conn,port);*/
365 BIO_set_conn_hostname(conn, s_time_config.host); 362 BIO_set_conn_hostname(conn, s_time_config.host);
366 363 SSL_set_connect_state(scon);
367 if (scon == NULL) 364 SSL_set_bio(scon, conn, conn);
368 serverCon = SSL_new(tm_ctx);
369 else {
370 serverCon = scon;
371 SSL_set_connect_state(serverCon);
372 }
373
374 SSL_set_bio(serverCon, conn, conn);
375
376 /* ok, lets connect */
377 for (;;) { 365 for (;;) {
378 i = SSL_connect(serverCon); 366 i = SSL_connect(scon);
379 if (BIO_sock_should_retry(i)) { 367 if (BIO_sock_should_retry(i)) {
380 BIO_printf(bio_err, "DELAY\n"); 368 BIO_printf(bio_err, "DELAY\n");
381 369 pfd[0].fd = SSL_get_fd(scon);
382 i = SSL_get_fd(serverCon);
383 pfd[0].fd = i;
384 pfd[0].events = POLLIN; 370 pfd[0].events = POLLIN;
385 poll(pfd, 1, -1); 371 poll(pfd, 1, -1);
386 continue; 372 continue;
@@ -389,17 +375,15 @@ doConnection(SSL * scon)
389 } 375 }
390 if (i <= 0) { 376 if (i <= 0) {
391 BIO_printf(bio_err, "ERROR\n"); 377 BIO_printf(bio_err, "ERROR\n");
392 verify_error = SSL_get_verify_result(serverCon); 378 verify_error = SSL_get_verify_result(scon);
393 if (verify_error != X509_V_OK) 379 if (verify_error != X509_V_OK)
394 BIO_printf(bio_err, "verify error:%s\n", 380 BIO_printf(bio_err, "verify error:%s\n",
395 X509_verify_cert_error_string(verify_error)); 381 X509_verify_cert_error_string(verify_error));
396 else 382 else
397 ERR_print_errors(bio_err); 383 ERR_print_errors(bio_err);
398 if (scon == NULL) 384 return 0;
399 SSL_free(serverCon);
400 return NULL;
401 } 385 }
402 return serverCon; 386 return 1;
403} 387}
404 388
405static int 389static int
@@ -415,7 +399,9 @@ benchmark(int reuse_session)
415 399
416 if (reuse_session) { 400 if (reuse_session) {
417 /* Get an SSL object so we can reuse the session id */ 401 /* Get an SSL object so we can reuse the session id */
418 if ((scon = doConnection(NULL)) == NULL) { 402 if ((scon = SSL_new(tm_ctx)) == NULL)
403 goto end;
404 if (!doConnection(scon)) {
419 fprintf(stderr, "Unable to get connection\n"); 405 fprintf(stderr, "Unable to get connection\n");
420 goto end; 406 goto end;
421 } 407 }
@@ -448,7 +434,11 @@ benchmark(int reuse_session)
448 for (;;) { 434 for (;;) {
449 if (finishtime < time(NULL)) 435 if (finishtime < time(NULL))
450 break; 436 break;
451 if ((scon = doConnection(reuse_session ? scon : NULL)) == NULL) 437 if (scon == NULL) {
438 if ((scon = SSL_new(tm_ctx)) == NULL)
439 goto end;
440 }
441 if (!doConnection(scon))
452 goto end; 442 goto end;
453 443
454 if (s_time_config.www_path != NULL) { 444 if (s_time_config.www_path != NULL) {