Skip to content

Commit 2a7ee21

Browse files
committed
tlshd: Add a command line option to disable verification
Currently, server verification for anonymous x.509 handshakes is commented out so we can test with prototype servers. However, server verification needs to be done normally. To enable testing to continue, make verification an opt-out instead of always off. Signed-off-by: Chuck Lever <[email protected]>
1 parent 5135000 commit 2a7ee21

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/tlshd/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@
4646

4747
#define TLSH_LISTENER_BACKLOG (20)
4848

49-
static const char *optstring = "dhl:v";
49+
int tlshd_verify_server = 1;
50+
51+
static const char *optstring = "dhl:nv";
5052
static const struct option longopts[] = {
5153
{ "debug", no_argument, NULL, 'd' },
5254
{ "help", no_argument, NULL, 'h' },
5355
{ "libdebug", required_argument, NULL, 'l' },
56+
{ "noverify", no_argument, NULL, 'n' },
5457
{ "version", no_argument, NULL, 'v' },
5558
{ NULL, 0, NULL, 0 }
5659
};
@@ -165,6 +168,9 @@ int main(int argc, char **argv)
165168
case 'l':
166169
tlshd_library_debug = atoi(optarg);
167170
break;
171+
case 'n':
172+
tlshd_verify_server = 0;
173+
break;
168174
case 'v':
169175
fprintf(stderr, "%s, built from " PACKAGE_STRING
170176
" on " __DATE__ " " __TIME__ "\n",

src/tlshd/tlshd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
extern int tlshd_debug;
2222
extern int tlshd_library_debug;
23+
extern int tlshd_verify_server;
2324

2425
/* handshake.c */
2526
extern void tlshd_client_handshake(gnutls_session_t session);

src/tlshd/tlshd.man

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ When specified tlshd displays a help message then exits immediately.
5050
When specified this option sets the debug level for the TLS library.
5151
By default, library debugging messages are disabled.
5252
.TP
53+
.B \-n " or " \-\-noverify
54+
When specified this option prevents
55+
.B tlshd
56+
from verifying the server's credential during anonymous handshakes.
57+
By default,
58+
.B tlshd
59+
verifies server credentials during anonymous handshakes.
60+
.IP
61+
Do not use this option on secure systems.
62+
.TP
5363
.B \-v " or " \-\-version
5464
When specified tlshd displays build version information then exits immediately.
5565
.SH ENVIRONMENT VARIABLES

src/tlshd/x509.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ static void tlshd_client_anon_x509_handshake(int sock, const char *peername)
8282

8383
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
8484

85-
/* Allow self-signed server certificates */
86-
//gnutls_session_set_verify_cert(session, peername, 0);
85+
if (tlshd_verify_server)
86+
gnutls_session_set_verify_cert(session, peername, 0);
8787

8888
ret = gnutls_set_default_priority(session);
8989
if (ret != GNUTLS_E_SUCCESS) {

0 commit comments

Comments
 (0)