aboutsummaryrefslogtreecommitdiffstats
path: root/main/libressl/s_client-add-options-verify_.patch
blob: 24048cea9e35cba606d6b64bf2bf9696284faa04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sun, 27 May 2018 22:08:00 +0200
Subject: [PATCH] s_client: Add options -verify_{hostname,email,ip}

This code is ported from OpenSSL 1.0.2o. We need it for Busybox wget.

--- a/apps/openssl/apps.c
+++ b/apps/openssl/apps.c
@@ -1845,6 +1845,9 @@
 	char **oldargs = *pargs;
 	char *arg = **pargs, *argn = (*pargs)[1];
 	time_t at_time = 0;
+	char *hostname = NULL;
+	char *email = NULL;
+	char *ipasc = NULL;
 	const char *errstr = NULL;
 
 	if (!strcmp(arg, "-policy")) {
@@ -1905,6 +1908,21 @@
 			at_time = (time_t) timestamp;
 		}
 		(*pargs)++;
+	} else if (strcmp(arg, "-verify_hostname") == 0) {
+		if (!argn)
+			*badarg = 1;
+		hostname = argn;
+		(*pargs)++;
+	} else if (strcmp(arg, "-verify_email") == 0) {
+		if (!argn)
+			*badarg = 1;
+		email = argn;
+		(*pargs)++;
+	} else if (strcmp(arg, "-verify_ip") == 0) {
+		if (!argn)
+			*badarg = 1;
+		ipasc = argn;
+		(*pargs)++;
 	} else if (!strcmp(arg, "-ignore_critical"))
 		flags |= X509_V_FLAG_IGNORE_CRITICAL;
 	else if (!strcmp(arg, "-issuer_checks"))
@@ -1958,6 +1976,15 @@
 
 	if (at_time)
 		X509_VERIFY_PARAM_set_time(*pm, at_time);
+
+	if (hostname && !X509_VERIFY_PARAM_set1_host(*pm, hostname, 0))
+		*badarg = 1;
+
+	if (email && !X509_VERIFY_PARAM_set1_email(*pm, email, 0))
+		*badarg = 1;
+
+	if (ipasc && !X509_VERIFY_PARAM_set1_ip_asc(*pm, ipasc))
+		*badarg = 1;
 
  end:
 	(*pargs)++;
--- a/apps/openssl/s_client.c
+++ b/apps/openssl/s_client.c
@@ -200,8 +200,12 @@
 	BIO_printf(bio_err, " -port port     - use -connect instead\n");
 	BIO_printf(bio_err, " -connect host:port - who to connect to (default is %s:%s)\n", SSL_HOST_NAME, PORT_STR);
 	BIO_printf(bio_err, " -proxy host:port - connect to http proxy\n");
+	BIO_printf(bio_err, " -verify_hostname host - check peer certificate matches \"host\"\n");
+	BIO_printf(bio_err, " -verify_email email - check peer certificate matches \"email\"\n");
+	BIO_printf(bio_err, " -verify_ip ipaddr - check peer certificate matches \"ipaddr\"\n");
 
 	BIO_printf(bio_err, " -verify arg   - turn on peer certificate verification\n");
+	BIO_printf(bio_err, " -verify_return_error - return verification errors\n");
 	BIO_printf(bio_err, " -cert arg     - certificate file to use, PEM format assumed\n");
 	BIO_printf(bio_err, " -certform arg - certificate format (PEM or DER) PEM default\n");
 	BIO_printf(bio_err, " -key arg      - Private key file to use, in cert file if\n");