diff options
author | Matt Caswell <matt@openssl.org> | 2023-06-07 16:26:58 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-06-14 13:08:37 +1000 |
commit | edd5b9d708d03ce1bdc1cbfc026ccc9183d586ad (patch) | |
tree | 1db109a0d7ae3c54990e30c7d9b046492b0270f7 | |
parent | 2df71d618505056f86cf4e033d9fdfcde0e6574a (diff) |
Fix minor issues in the demo/man pages for TLS client/blocking
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21133)
-rw-r--r-- | demos/guide/tls-client-block.c | 4 | ||||
-rw-r--r-- | doc/man7/ossl-guide-tls-client-block.pod | 14 |
2 files changed, 10 insertions, 8 deletions
diff --git a/demos/guide/tls-client-block.c b/demos/guide/tls-client-block.c index 56133aab64..ef8248c734 100644 --- a/demos/guide/tls-client-block.c +++ b/demos/guide/tls-client-block.c @@ -37,10 +37,8 @@ static BIO *create_socket_bio(const char *hostname, const char *port) * Lookup IP address info for the server. */ if (!BIO_lookup_ex(hostname, port, BIO_LOOKUP_CLIENT, 0, SOCK_STREAM, 0, - &res)) { - BIO_closesocket(sock); + &res)) return NULL; - } /* * Loop through all the possible addresses for the server and find one diff --git a/doc/man7/ossl-guide-tls-client-block.pod b/doc/man7/ossl-guide-tls-client-block.pod index 30832c5b20..aab5533f5e 100644 --- a/doc/man7/ossl-guide-tls-client-block.pod +++ b/doc/man7/ossl-guide-tls-client-block.pod @@ -166,16 +166,16 @@ provide the POSIX compatible I<connect> function. For example: OpenSSL provides portable helper functions to do these tasks which also integrate into the OpenSSL error system to log error data, e.g. - BIO_ADDRINFO *ai = NULL; + int sock = -1; + BIO_ADDRINFO *res; + const BIO_ADDRINFO *ai = NULL; /* * Lookup IP address info for the server. */ if (!BIO_lookup_ex(hostname, port, BIO_LOOKUP_CLIENT, 0, SOCK_STREAM, 0, - &res)) { - BIO_closesocket(sock); + &res)) return NULL; - } /* * Loop through all the possible addresses for the server and find one @@ -199,6 +199,9 @@ integrate into the OpenSSL error system to log error data, e.g. sock = -1; continue; } + + /* We have a connected socket so break out of the loop */ + break; } /* Free the address information resources we allocated earlier */ @@ -342,7 +345,8 @@ data from the server we use the L<SSL_read_ex(3)> function. In HTTP 1.0 the client always writes data first. size_t written; - const char *request = "GET / HTTP/1.0\r\nHost: "HOSTNAME"\r\n\r\n"; + const char *request = + "GET / HTTP/1.0\r\nConnection: close\r\nHost: "HOSTNAME"\r\n\r\n"; /* Write an HTTP GET request to the peer */ if (!SSL_write_ex(ssl, request, strlen(request), &written)) { |