|
@@ -124,6 +124,8 @@ char *http_method;
|
|
|
char *http_post_data;
|
|
char *http_post_data;
|
|
|
char *http_content_type;
|
|
char *http_content_type;
|
|
|
char buffer[MAX_INPUT_BUFFER];
|
|
char buffer[MAX_INPUT_BUFFER];
|
|
|
|
|
+char *client_cert = NULL;
|
|
|
|
|
+char *client_privkey = NULL;
|
|
|
|
|
|
|
|
int process_arguments (int, char **);
|
|
int process_arguments (int, char **);
|
|
|
int check_http (void);
|
|
int check_http (void);
|
|
@@ -170,7 +172,14 @@ main (int argc, char **argv)
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+/* check whether a file exists */
|
|
|
|
|
+void
|
|
|
|
|
+test_file (char *path)
|
|
|
|
|
+{
|
|
|
|
|
+ if (access(path, R_OK) == 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ usage2 (_("file does not exist or is not readable"), path);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/* process command-line arguments */
|
|
/* process command-line arguments */
|
|
|
int
|
|
int
|
|
@@ -207,6 +216,8 @@ process_arguments (int argc, char **argv)
|
|
|
{"linespan", no_argument, 0, 'l'},
|
|
{"linespan", no_argument, 0, 'l'},
|
|
|
{"onredirect", required_argument, 0, 'f'},
|
|
{"onredirect", required_argument, 0, 'f'},
|
|
|
{"certificate", required_argument, 0, 'C'},
|
|
{"certificate", required_argument, 0, 'C'},
|
|
|
|
|
+ {"client-cert", required_argument, 0, 'E'},
|
|
|
|
|
+ {"private-key", required_argument, 0, 'K'},
|
|
|
{"useragent", required_argument, 0, 'A'},
|
|
{"useragent", required_argument, 0, 'A'},
|
|
|
{"header", required_argument, 0, 'k'},
|
|
{"header", required_argument, 0, 'k'},
|
|
|
{"no-body", no_argument, 0, 'N'},
|
|
{"no-body", no_argument, 0, 'N'},
|
|
@@ -236,7 +247,7 @@ process_arguments (int argc, char **argv)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
|
while (1) {
|
|
|
- c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:R:r:u:f:C:nlLS::m:M:N", longopts, &option);
|
|
|
|
|
|
|
+ c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:R:r:u:f:C:E:K:nlLS::m:M:N", longopts, &option);
|
|
|
if (c == -1 || c == EOF)
|
|
if (c == -1 || c == EOF)
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -301,10 +312,23 @@ process_arguments (int argc, char **argv)
|
|
|
days_till_exp_warn = atoi (optarg);
|
|
days_till_exp_warn = atoi (optarg);
|
|
|
}
|
|
}
|
|
|
check_cert = TRUE;
|
|
check_cert = TRUE;
|
|
|
- /* Fall through to -S option */
|
|
|
|
|
|
|
+ goto enable_ssl;
|
|
|
|
|
+#endif
|
|
|
|
|
+ case 'E': /* use client certificate */
|
|
|
|
|
+#ifdef HAVE_SSL
|
|
|
|
|
+ test_file(optarg);
|
|
|
|
|
+ client_cert = optarg;
|
|
|
|
|
+ goto enable_ssl;
|
|
|
|
|
+#endif
|
|
|
|
|
+ case 'K': /* use client private key */
|
|
|
|
|
+#ifdef HAVE_SSL
|
|
|
|
|
+ test_file(optarg);
|
|
|
|
|
+ client_privkey = optarg;
|
|
|
|
|
+ goto enable_ssl;
|
|
|
#endif
|
|
#endif
|
|
|
case 'S': /* use SSL */
|
|
case 'S': /* use SSL */
|
|
|
#ifdef HAVE_SSL
|
|
#ifdef HAVE_SSL
|
|
|
|
|
+ enable_ssl:
|
|
|
use_ssl = TRUE;
|
|
use_ssl = TRUE;
|
|
|
if (optarg == NULL || c != 'S')
|
|
if (optarg == NULL || c != 'S')
|
|
|
ssl_version = 0;
|
|
ssl_version = 0;
|
|
@@ -316,6 +340,7 @@ process_arguments (int argc, char **argv)
|
|
|
if (specify_port == FALSE)
|
|
if (specify_port == FALSE)
|
|
|
server_port = HTTPS_PORT;
|
|
server_port = HTTPS_PORT;
|
|
|
#else
|
|
#else
|
|
|
|
|
+ /* -C -E and -K fall through to here without SSL */
|
|
|
usage4 (_("Invalid option - SSL is not available"));
|
|
usage4 (_("Invalid option - SSL is not available"));
|
|
|
#endif
|
|
#endif
|
|
|
break;
|
|
break;
|
|
@@ -497,6 +522,9 @@ process_arguments (int argc, char **argv)
|
|
|
if (http_method == NULL)
|
|
if (http_method == NULL)
|
|
|
http_method = strdup ("GET");
|
|
http_method = strdup ("GET");
|
|
|
|
|
|
|
|
|
|
+ if (client_cert && !client_privkey)
|
|
|
|
|
+ usage4 (_("If you use a client certificate you must also specify a private key file"));
|
|
|
|
|
+
|
|
|
return TRUE;
|
|
return TRUE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -820,7 +848,7 @@ check_http (void)
|
|
|
die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n"));
|
|
die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n"));
|
|
|
#ifdef HAVE_SSL
|
|
#ifdef HAVE_SSL
|
|
|
if (use_ssl == TRUE) {
|
|
if (use_ssl == TRUE) {
|
|
|
- result = np_net_ssl_init_with_hostname_and_version(sd, (use_sni ? host_name : NULL), ssl_version);
|
|
|
|
|
|
|
+ result = np_net_ssl_init_with_hostname_version_and_certificate(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey);
|
|
|
if (result != STATE_OK)
|
|
if (result != STATE_OK)
|
|
|
return result;
|
|
return result;
|
|
|
if (check_cert == TRUE) {
|
|
if (check_cert == TRUE) {
|
|
@@ -1354,7 +1382,13 @@ print_help (void)
|
|
|
printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
|
|
printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
|
|
|
printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
|
|
printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
|
|
|
printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
|
|
printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
|
|
|
- printf (" %s\n", _("(when this option is used the URL is not checked.)\n"));
|
|
|
|
|
|
|
+ printf (" %s\n", _("(when this option is used the URL is not checked.)"));
|
|
|
|
|
+ printf (" %s\n", "-E, --client-cert=FILE");
|
|
|
|
|
+ printf (" %s\n", _("Name of file that contains the client certificate (PEM format)"));
|
|
|
|
|
+ printf (" %s\n", _("to be used in establishing the SSL session"));
|
|
|
|
|
+ printf (" %s\n", "-K, --private-key=FILE");
|
|
|
|
|
+ printf (" %s\n", _("Name of file containing the private key (PEM format)"));
|
|
|
|
|
+ printf (" %s\n", _("matching the client certificate"));
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
printf (" %s\n", "-e, --expect=STRING");
|
|
printf (" %s\n", "-e, --expect=STRING");
|
|
@@ -1461,6 +1495,7 @@ print_usage (void)
|
|
|
{
|
|
{
|
|
|
printf ("%s\n", _("Usage:"));
|
|
printf ("%s\n", _("Usage:"));
|
|
|
printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
|
|
printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
|
|
|
|
|
+ printf (" [-E <client certificate file>] [-K <private key>]\n");
|
|
|
printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-a auth]\n");
|
|
printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-a auth]\n");
|
|
|
printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n");
|
|
printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n");
|
|
|
printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
|
|
printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
|