Fix typo in CONTRIBUTING.md
[openssl.git] / demos / bio / client-arg.c
index 99ebff1f2a94626e6376fc9205e553806d6288a1..c4abdf5cd351e8a08294321f1c26a5c3e46ebe80 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * Copyright 2013-2023 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
+ * this file except in compliance with the License.  You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <string.h>
 #include <openssl/err.h>
 #include <openssl/ssl.h>
 
@@ -12,10 +22,7 @@ int main(int argc, char **argv)
     char **args = argv + 1;
     const char *connect_str = "localhost:4433";
     int nargs = argc - 1;
-
-    ERR_load_crypto_strings();
-    ERR_load_SSL_strings();
-    SSL_library_init();
+    int ret = EXIT_FAILURE;
 
     ctx = SSL_CTX_new(TLS_client_method());
     cctx = SSL_CONF_CTX_new();
@@ -56,7 +63,7 @@ int main(int argc, char **argv)
     if (!SSL_CONF_CTX_finish(cctx)) {
         fprintf(stderr, "Finish error\n");
         ERR_print_errors_fp(stderr);
-        goto err;
+        goto end;
     }
 
     /*
@@ -74,9 +81,6 @@ int main(int argc, char **argv)
         goto end;
     }
 
-    /* Don't want any retries */
-    SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
-
     /* We might want to do other things with ssl here */
 
     BIO_set_conn_hostname(sbio, connect_str);
@@ -88,12 +92,6 @@ int main(int argc, char **argv)
         goto end;
     }
 
-    if (BIO_do_handshake(sbio) <= 0) {
-        fprintf(stderr, "Error establishing SSL connection\n");
-        ERR_print_errors_fp(stderr);
-        goto end;
-    }
-
     /* Could examine ssl here to get connection info */
 
     BIO_puts(sbio, "GET / HTTP/1.0\n\n");
@@ -103,9 +101,10 @@ int main(int argc, char **argv)
             break;
         BIO_write(out, tmpbuf, len);
     }
+    ret = EXIT_SUCCESS;
  end:
     SSL_CONF_CTX_free(cctx);
     BIO_free_all(sbio);
     BIO_free(out);
-    return 0;
+    return ret;
 }