Skip to content

Commit

Permalink
openssl: remove obsolete function tls_set_hostname()
Browse files Browse the repository at this point in the history
- Wrong pointer notation in first parameter (char * instead of char **). But
  the function can be removed for simplicity.
- Renames also http_cli.tls_hostname to http_cli.tlshn which might be more
  libre conform naming style.
  • Loading branch information
cspiel1 committed Oct 16, 2020
1 parent 3a22f91 commit 1fae071
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
1 change: 0 additions & 1 deletion include/re_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ int tls_peer_fingerprint(const struct tls_conn *tc, enum tls_fingerprint type,
int tls_peer_common_name(const struct tls_conn *tc, char *cn, size_t size);
int tls_peer_set_verify_host(struct tls_conn *tc, const char *hostname);
int tls_set_verify_purpose(struct tls *tls, const char *purpose);
int tls_set_hostname(char *tls_hostname, const struct pl *hostname);
int tls_peer_verify(const struct tls_conn *tc);
int tls_srtp_keyinfo(const struct tls_conn *tc, enum srtp_suite *suite,
uint8_t *cli_key, size_t cli_key_size,
Expand Down
16 changes: 10 additions & 6 deletions src/http/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct http_cli {
struct hash *ht_conn;
struct dnsc *dnsc;
struct tls *tls;
char *tls_hostname;
char *tlshn;
char *cert;
char *key;
struct sa laddr;
Expand Down Expand Up @@ -113,7 +113,7 @@ static void cli_destructor(void *arg)
mem_deref(cli->key);
mem_deref(cli->dnsc);
mem_deref(cli->tls);
mem_deref(cli->tls_hostname);
mem_deref(cli->tlshn);
}


Expand Down Expand Up @@ -472,9 +472,9 @@ static int conn_connect(struct http_req *req)
if (err)
goto out;

if (req->cli->tls_hostname)
if (req->cli->tlshn)
err = tls_peer_set_verify_host(conn->sc,
req->cli->tls_hostname);
req->cli->tlshn);

if (err)
goto out;
Expand Down Expand Up @@ -945,10 +945,14 @@ int http_client_set_keypem(struct http_cli *cli, const char *pem)
int http_client_set_tls_hostname(struct http_cli *cli,
const struct pl *hostname)
{
if (!cli || !hostname)
if (!cli)
return EINVAL;

return tls_set_hostname(cli->tls_hostname, hostname);
cli->tlshn = mem_deref(cli->tlshn);
if (!hostname)
return 0;

return pl_strdup(&cli->tlshn, hostname);
}
#endif

Expand Down
22 changes: 0 additions & 22 deletions src/tls/openssl/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,28 +333,6 @@ int tls_peer_set_verify_host(struct tls_conn *tc, const char *hostname)
}


/**
* Convert string hostname to pl hostname
*
* @param tls_hostname Certificate hostname as string
* @param hostname Certificate hostname as pl
*
* @return int 0 if success, errorcode otherwise
*/
int tls_set_hostname(char *tls_hostname, const struct pl *hostname)
{
if (!tls_hostname || !hostname)
return EINVAL;

#if OPENSSL_VERSION_NUMBER < 0x10100000L
DEBUG_WARNING("verify hostname needs openssl version 1.1.0\n");
return ENOSYS;
#endif

return pl_strdup(&tls_hostname, hostname);
}


/**
* Generate and set selfsigned certificate on TLS context
*
Expand Down

0 comments on commit 1fae071

Please sign in to comment.