Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable_verify_server_general #76

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/re_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ int tls_set_verify_server(struct tls_conn *tc, const char *host);

int tls_get_issuer(struct tls *tls, struct mbuf *mb);
int tls_get_subject(struct tls *tls, struct mbuf *mb);
void tls_disable_verify_server(struct tls *tls);

/* TCP */

Expand Down
5 changes: 2 additions & 3 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ static int conn_send(struct sip_connqent **qentp, struct sip *sip, bool secure,
struct sip_connqent *qent;
int err = 0;

#ifndef SIP_VERIFY_SERVER
#ifndef USE_TLS
(void) host;
#endif

Expand Down Expand Up @@ -687,11 +687,10 @@ static int conn_send(struct sip_connqent **qentp, struct sip *sip, bool secure,
err = tls_start_tcp(&conn->sc, transp->tls, conn->tc, 0);
if (err)
goto out;
#ifdef SIP_VERIFY_SERVER

err = tls_set_verify_server(conn->sc, host);
if (err)
goto out;
#endif
}
#endif

Expand Down
19 changes: 19 additions & 0 deletions src/tls/openssl/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/* NOTE: shadow struct defined in tls_*.c */
struct tls_conn {
SSL *ssl;
struct tls *tls;
};


Expand Down Expand Up @@ -142,6 +143,7 @@ int tls_alloc(struct tls **tlsp, enum tls_method method, const char *keyfile,
if (!tls)
return ENOMEM;

tls->verify_server = true;
switch (method) {

case TLS_METHOD_SSLV23:
Expand Down Expand Up @@ -1106,6 +1108,9 @@ int tls_set_verify_server(struct tls_conn *tc, const char *host)
if (!tc || !host)
return EINVAL;

if (!tc->tls->verify_server)
return 0;

if (sa_set_str(&sa, host, 0)) {
SSL_set_hostflags(tc->ssl,
X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
Expand Down Expand Up @@ -1287,3 +1292,17 @@ int tls_get_subject(struct tls *tls, struct mbuf *mb)
return tls_get_ca_chain_field(tls, mb, &X509_get_subject_name,
XN_FLAG_RFC2253);
}


/**
* Disables SIP TLS server verifications for following requests
*
* @param tls TLS Object
*/
void tls_disable_verify_server(struct tls *tls)
{
if (!tls)
return;

tls->verify_server = false;
}
3 changes: 2 additions & 1 deletion src/tls/openssl/tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ typedef X509_NAME*(tls_get_certfield_h)(X509 *);
struct tls {
SSL_CTX *ctx;
X509 *cert;
char *pass; /* password for private key */
char *pass; /**< password for private key */
bool verify_server; /**< Enable SIP TLS server verification */
};


Expand Down
4 changes: 3 additions & 1 deletion src/tls/openssl/tls_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

/* NOTE: shadow struct defined in tls_*.c */
struct tls_conn {
SSL *ssl;
SSL *ssl; /* inheritance */
struct tls *tls; /* inheritance */
#ifdef TLS_BIO_OPAQUE
BIO_METHOD *biomet;
#endif
Expand Down Expand Up @@ -375,6 +376,7 @@ int tls_start_tcp(struct tls_conn **ptc, struct tls *tls, struct tcp_conn *tcp,
goto out;

tc->tcp = mem_ref(tcp);
tc->tls = tls;

#ifdef TLS_BIO_OPAQUE
tc->biomet = bio_method_tcp();
Expand Down
2 changes: 2 additions & 0 deletions src/tls/openssl/tls_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct dtls_sock {
/* NOTE: shadow struct defined in tls_*.c */
struct tls_conn {
SSL *ssl; /* inheritance */
struct tls *tls; /* inheritance */
#ifdef TLS_BIO_OPAQUE
BIO_METHOD *biomet;
#endif
Expand Down Expand Up @@ -479,6 +480,7 @@ static int conn_alloc(struct tls_conn **ptc, struct tls *tls,
tc->recvh = recvh;
tc->closeh = closeh;
tc->arg = arg;
tc->tls = tls;

#ifdef TLS_BIO_OPAQUE
tc->biomet = bio_method_udp();
Expand Down