check_tcp.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*****************************************************************************
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  13. $Id$
  14. *****************************************************************************/
  15. /* progname "check_tcp" changes depending on symlink called */
  16. char *progname;
  17. const char *revision = "$Revision$";
  18. const char *copyright = "1999-2004";
  19. const char *email = "nagiosplug-devel@lists.sourceforge.net";
  20. #include "common.h"
  21. #include "netutils.h"
  22. #include "utils.h"
  23. #ifdef HAVE_SSL
  24. static int check_cert = FALSE;
  25. static int days_till_exp;
  26. static char *randbuff = "";
  27. # define my_recv(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
  28. # define my_send(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
  29. #else
  30. # define my_recv(buf, len) read(sd, buf, len)
  31. # define my_send(buf, len) send(sd, buf, len, 0)
  32. #endif
  33. /* int my_recv(char *, size_t); */
  34. static int process_arguments (int, char **);
  35. void print_help (void);
  36. void print_usage (void);
  37. #define EXPECT server_expect[0]
  38. static char *SERVICE = "TCP";
  39. static char *SEND = NULL;
  40. static char *QUIT = NULL;
  41. static int PROTOCOL = IPPROTO_TCP; /* most common is default */
  42. static int PORT = 0;
  43. static char timestamp[17] = "";
  44. static int server_port = 0;
  45. static char *server_address = NULL;
  46. static char *server_send = NULL;
  47. static char *server_quit = NULL;
  48. static char **server_expect;
  49. static size_t server_expect_count = 0;
  50. static size_t maxbytes = 0;
  51. static char **warn_codes = NULL;
  52. static size_t warn_codes_count = 0;
  53. static char **crit_codes = NULL;
  54. static size_t crit_codes_count = 0;
  55. static unsigned int delay = 0;
  56. static double warning_time = 0;
  57. static double critical_time = 0;
  58. static double elapsed_time = 0;
  59. static long microsec;
  60. static int sd = 0;
  61. #define MAXBUF 1024
  62. static char buffer[MAXBUF];
  63. static int expect_mismatch_state = STATE_WARNING;
  64. #define FLAG_SSL 0x01
  65. #define FLAG_VERBOSE 0x02
  66. #define FLAG_EXACT_MATCH 0x04
  67. #define FLAG_TIME_WARN 0x08
  68. #define FLAG_TIME_CRIT 0x10
  69. #define FLAG_HIDE_OUTPUT 0x20
  70. static size_t flags = FLAG_EXACT_MATCH;
  71. int
  72. main (int argc, char **argv)
  73. {
  74. int result = STATE_UNKNOWN;
  75. int i;
  76. char *status = NULL;
  77. struct timeval tv;
  78. size_t len, match = -1;
  79. setlocale (LC_ALL, "");
  80. bindtextdomain (PACKAGE, LOCALEDIR);
  81. textdomain (PACKAGE);
  82. /* determine program- and service-name quickly */
  83. progname = strrchr(argv[0], '/');
  84. if(progname != NULL) progname++;
  85. else progname = argv[0];
  86. len = strlen(progname);
  87. if(len > 6 && !memcmp(progname, "check_", 6)) {
  88. SERVICE = progname + 6;
  89. for(i = 0; i < len - 6; i++)
  90. SERVICE[i] = toupper(SERVICE[i]);
  91. }
  92. /* set up a resonable buffer at first (will be realloc()'ed if
  93. * user specifies other options) */
  94. server_expect = calloc(sizeof(char *), 2);
  95. /* determine defaults for this service's protocol */
  96. if (!strncmp(SERVICE, "UDP", 3)) {
  97. PROTOCOL = IPPROTO_UDP;
  98. }
  99. else if (!strncmp(SERVICE, "FTP", 3)) {
  100. EXPECT = "220";
  101. QUIT = "QUIT\r\n";
  102. PORT = 21;
  103. }
  104. else if (!strncmp(SERVICE, "POP", 3) || !strncmp(SERVICE, "POP3", 4)) {
  105. EXPECT = "+OK";
  106. QUIT = "QUIT\r\n";
  107. PORT = 110;
  108. }
  109. else if (!strncmp(SERVICE, "SMTP", 4)) {
  110. EXPECT = "220";
  111. QUIT = "QUIT\r\n";
  112. PORT = 25;
  113. }
  114. else if (!strncmp(SERVICE, "IMAP", 4)) {
  115. EXPECT = "* OK";
  116. QUIT = "a1 LOGOUT\r\n";
  117. PORT = 143;
  118. }
  119. #ifdef HAVE_SSL
  120. else if (!strncmp(SERVICE, "SIMAP", 5)) {
  121. EXPECT = "* OK";
  122. QUIT = "a1 LOGOUT\r\n";
  123. flags |= FLAG_SSL;
  124. PORT = 993;
  125. }
  126. else if (!strncmp(SERVICE, "SPOP", 4)) {
  127. EXPECT = "+OK";
  128. QUIT = "QUIT\r\n";
  129. flags |= FLAG_SSL;
  130. PORT = 995;
  131. }
  132. else if (!strncmp(SERVICE, "SSMTP", 5)) {
  133. EXPECT = "220";
  134. QUIT = "QUIT\r\n";
  135. flags |= FLAG_SSL;
  136. PORT = 465;
  137. }
  138. else if (!strncmp(SERVICE, "JABBER", 6)) {
  139. SEND = "<stream:stream to=\'host\' xmlns=\'jabber:client\' xmlns:stream=\'http://etherx.jabber.org/streams\'>\n";
  140. EXPECT = "<?xml version=\'1.0\'?><stream:stream xmlns:stream=\'http://etherx.jabber.org/streams\'";
  141. QUIT = "</stream:stream>\n";
  142. flags |= FLAG_SSL | FLAG_HIDE_OUTPUT;
  143. PORT = 5222;
  144. }
  145. else if (!strncmp (SERVICE, "NNTPS", 5)) {
  146. server_expect_count = 2;
  147. server_expect[0] = "200";
  148. server_expect[1] = "201";
  149. QUIT = "QUIT\r\n";
  150. flags |= FLAG_SSL;
  151. PORT = 563;
  152. }
  153. #endif
  154. else if (!strncmp (SERVICE, "NNTP", 4)) {
  155. server_expect_count = 2;
  156. server_expect = malloc(sizeof(char *) * server_expect_count);
  157. server_expect[0] = strdup("200");
  158. server_expect[1] = strdup("201");
  159. QUIT = "QUIT\r\n";
  160. PORT = 119;
  161. }
  162. else if (strncmp(SERVICE, "CLAMD", 5)) {
  163. SEND = "PING";
  164. EXPECT = "PONG";
  165. QUIT = NULL;
  166. PORT = 3310;
  167. }
  168. /* fallthrough check, so it's supposed to use reverse matching */
  169. else if (strcmp (SERVICE, "TCP"))
  170. usage (_("CRITICAL - Generic check_tcp called with unknown service\n"));
  171. server_address = "127.0.0.1";
  172. server_port = PORT;
  173. server_send = SEND;
  174. server_quit = QUIT;
  175. status = NULL;
  176. if (process_arguments (argc, argv) == ERROR)
  177. usage4 (_("Could not parse arguments"));
  178. if(flags & FLAG_VERBOSE) {
  179. printf("Using service %s\n", SERVICE);
  180. printf("Port: %d\n", PORT);
  181. printf("flags: 0x%x\n", flags);
  182. }
  183. if(EXPECT && !server_expect_count)
  184. server_expect_count++;
  185. /* set up the timer */
  186. signal (SIGALRM, socket_timeout_alarm_handler);
  187. alarm (socket_timeout);
  188. /* try to connect to the host at the given port number */
  189. gettimeofday (&tv, NULL);
  190. result = np_net_connect (server_address, server_port, &sd, PROTOCOL);
  191. if (result == STATE_CRITICAL) return STATE_CRITICAL;
  192. #ifdef HAVE_SSL
  193. if (flags & FLAG_SSL){
  194. result = np_net_ssl_init(sd);
  195. if (result == STATE_OK && check_cert == TRUE) {
  196. result = np_net_ssl_check_cert(days_till_exp);
  197. if(result != STATE_OK) {
  198. printf(_("CRITICAL - Cannot retrieve server certificate.\n"));
  199. }
  200. }
  201. }
  202. if(result != STATE_OK){
  203. np_net_ssl_cleanup();
  204. if(sd) close(sd);
  205. return result;
  206. }
  207. #endif /* HAVE_SSL */
  208. if (server_send != NULL) { /* Something to send? */
  209. my_send(server_send, strlen(server_send));
  210. }
  211. if (delay > 0) {
  212. tv.tv_sec += delay;
  213. sleep (delay);
  214. }
  215. if(flags & FLAG_VERBOSE) {
  216. printf("server_expect_count: %d\n", server_expect_count);
  217. for(i = 0; i < server_expect_count; i++)
  218. printf("\t%d: %s\n", i, server_expect[i]);
  219. }
  220. /* if(len) later on, we know we have a non-NULL response */
  221. len = 0;
  222. if (server_expect_count) {
  223. /* watch for the expect string */
  224. while ((i = my_recv(buffer, sizeof(buffer))) > 0) {
  225. status = realloc(status, len + i + 1);
  226. memcpy(&status[len], buffer, i);
  227. len += i;
  228. /* stop reading if user-forced or data-starved */
  229. if(i < sizeof(buffer) || (maxbytes && len >= maxbytes))
  230. break;
  231. if (maxbytes && len >= maxbytes)
  232. break;
  233. }
  234. /* no data when expected, so return critical */
  235. if (len == 0)
  236. die (STATE_CRITICAL, _("No data received from host\n"));
  237. /* force null-termination and strip whitespace from end of output */
  238. status[len--] = '\0';
  239. /* print raw output if we're debugging */
  240. if(flags & FLAG_VERBOSE)
  241. printf("received %d bytes from host\n#-raw-recv-------#\n%s\n#-raw-recv-------#\n",
  242. len + 1, status);
  243. while(isspace(status[len])) status[len--] = '\0';
  244. for (i = 0; i < server_expect_count; i++) {
  245. match = -2; /* tag it so we know if we tried and failed */
  246. if (flags & FLAG_VERBOSE)
  247. printf ("looking for [%s] %s [%s]\n", server_expect[i],
  248. (flags & FLAG_EXACT_MATCH) ? "in beginning of" : "anywhere in",
  249. status);
  250. /* match it. math first in short-circuit */
  251. if ((flags & FLAG_EXACT_MATCH && !strncmp(status, server_expect[i], strlen(server_expect[i]))) ||
  252. (!(flags & FLAG_EXACT_MATCH) && strstr(status, server_expect[i])))
  253. {
  254. if(flags & FLAG_VERBOSE) puts("found it");
  255. match = i;
  256. break;
  257. }
  258. }
  259. }
  260. if (server_quit != NULL) {
  261. my_send(server_quit, strlen(server_quit));
  262. }
  263. #ifdef HAVE_SSL
  264. np_net_ssl_cleanup();
  265. #endif
  266. if (sd) close (sd);
  267. microsec = deltime (tv);
  268. elapsed_time = (double)microsec / 1.0e6;
  269. if (flags & FLAG_TIME_CRIT && elapsed_time > critical_time)
  270. result = STATE_CRITICAL;
  271. else if (flags & FLAG_TIME_WARN && elapsed_time > warning_time)
  272. result = STATE_WARNING;
  273. /* did we get the response we hoped? */
  274. if(match == -2 && result != STATE_CRITICAL)
  275. result = STATE_WARNING;
  276. /* reset the alarm */
  277. alarm (0);
  278. /* this is a bit stupid, because we don't want to print the
  279. * response time (which can look ok to the user) if we didn't get
  280. * the response we were looking for. if-else */
  281. printf(_("%s %s - "), SERVICE, state_text(result));
  282. if(match == -2 && len && !(flags & FLAG_HIDE_OUTPUT))
  283. printf("Unexpected response from host/socket: %s", status);
  284. else {
  285. printf("%.3f second response time on ", elapsed_time);
  286. if(server_address[0] != '/')
  287. printf("port %d", server_port);
  288. else
  289. printf("socket %s", server_address);
  290. }
  291. if (match != -2 && !(flags & FLAG_HIDE_OUTPUT) && len)
  292. printf (" [%s]", status);
  293. /* perf-data doesn't apply when server doesn't talk properly,
  294. * so print all zeroes on warn and crit */
  295. if(match == -2)
  296. printf ("|time=%fs;0.0;0.0;0.0;0.0", elapsed_time);
  297. else
  298. printf("|%s",
  299. fperfdata ("time", elapsed_time, "s",
  300. TRUE, warning_time,
  301. TRUE, critical_time,
  302. TRUE, 0,
  303. TRUE, socket_timeout)
  304. );
  305. putchar('\n');
  306. return result;
  307. }
  308. /* process command-line arguments */
  309. static int
  310. process_arguments (int argc, char **argv)
  311. {
  312. int c;
  313. int option = 0;
  314. static struct option longopts[] = {
  315. {"hostname", required_argument, 0, 'H'},
  316. {"critical-time", required_argument, 0, 'c'},
  317. {"warning-time", required_argument, 0, 'w'},
  318. {"critical-codes", required_argument, 0, 'C'},
  319. {"warning-codes", required_argument, 0, 'W'},
  320. {"timeout", required_argument, 0, 't'},
  321. {"protocol", required_argument, 0, 'P'},
  322. {"port", required_argument, 0, 'p'},
  323. {"send", required_argument, 0, 's'},
  324. {"expect", required_argument, 0, 'e'},
  325. {"maxbytes", required_argument, 0, 'm'},
  326. {"quit", required_argument, 0, 'q'},
  327. {"jail", required_argument, 0, 'j'},
  328. {"delay", required_argument, 0, 'd'},
  329. {"refuse", required_argument, 0, 'r'},
  330. {"mismatch", required_argument, 0, 'M'},
  331. {"use-ipv4", no_argument, 0, '4'},
  332. {"use-ipv6", no_argument, 0, '6'},
  333. {"verbose", no_argument, 0, 'v'},
  334. {"version", no_argument, 0, 'V'},
  335. {"help", no_argument, 0, 'h'},
  336. #ifdef HAVE_SSL
  337. {"ssl", no_argument, 0, 'S'},
  338. {"certificate", required_argument, 0, 'D'},
  339. #endif
  340. {0, 0, 0, 0}
  341. };
  342. if (argc < 2)
  343. usage4 (_("No arguments found"));
  344. /* backwards compatibility */
  345. for (c = 1; c < argc; c++) {
  346. if (strcmp ("-to", argv[c]) == 0)
  347. strcpy (argv[c], "-t");
  348. else if (strcmp ("-wt", argv[c]) == 0)
  349. strcpy (argv[c], "-w");
  350. else if (strcmp ("-ct", argv[c]) == 0)
  351. strcpy (argv[c], "-c");
  352. }
  353. if (!is_option (argv[1])) {
  354. server_address = argv[1];
  355. argv[1] = argv[0];
  356. argv = &argv[1];
  357. argc--;
  358. }
  359. while (1) {
  360. c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:",
  361. longopts, &option);
  362. if (c == -1 || c == EOF || c == 1)
  363. break;
  364. switch (c) {
  365. case '?': /* print short usage statement if args not parsable */
  366. usage2 (_("Unknown argument"), optarg);
  367. case 'h': /* help */
  368. print_help ();
  369. exit (STATE_OK);
  370. case 'V': /* version */
  371. print_revision (progname, revision);
  372. exit (STATE_OK);
  373. case 'v': /* verbose mode */
  374. flags |= FLAG_VERBOSE;
  375. break;
  376. case '4':
  377. address_family = AF_INET;
  378. break;
  379. case '6':
  380. #ifdef USE_IPV6
  381. address_family = AF_INET6;
  382. #else
  383. usage4 (_("IPv6 support not available"));
  384. #endif
  385. break;
  386. case 'H': /* hostname */
  387. server_address = optarg;
  388. break;
  389. case 'c': /* critical */
  390. if (!is_intnonneg (optarg))
  391. usage4 (_("Critical threshold must be a positive integer"));
  392. else
  393. critical_time = strtod (optarg, NULL);
  394. flags |= FLAG_TIME_CRIT;
  395. break;
  396. case 'j': /* hide output */
  397. flags |= FLAG_HIDE_OUTPUT;
  398. break;
  399. case 'w': /* warning */
  400. if (!is_intnonneg (optarg))
  401. usage4 (_("Warning threshold must be a positive integer"));
  402. else
  403. warning_time = strtod (optarg, NULL);
  404. flags |= FLAG_TIME_WARN;
  405. break;
  406. case 'C':
  407. crit_codes = realloc (crit_codes, ++crit_codes_count);
  408. crit_codes[crit_codes_count - 1] = optarg;
  409. break;
  410. case 'W':
  411. warn_codes = realloc (warn_codes, ++warn_codes_count);
  412. warn_codes[warn_codes_count - 1] = optarg;
  413. break;
  414. case 't': /* timeout */
  415. if (!is_intpos (optarg))
  416. usage4 (_("Timeout interval must be a positive integer"));
  417. else
  418. socket_timeout = atoi (optarg);
  419. break;
  420. case 'p': /* port */
  421. if (!is_intpos (optarg))
  422. usage4 (_("Port must be a positive integer"));
  423. else
  424. server_port = atoi (optarg);
  425. break;
  426. case 's':
  427. server_send = optarg;
  428. break;
  429. case 'e': /* expect string (may be repeated) */
  430. EXPECT = NULL;
  431. flags &= ~FLAG_EXACT_MATCH;
  432. if (server_expect_count == 0)
  433. server_expect = malloc (sizeof (char *) * (++server_expect_count));
  434. else
  435. server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count));
  436. server_expect[server_expect_count - 1] = optarg;
  437. break;
  438. case 'm':
  439. if (!is_intpos (optarg))
  440. usage4 (_("Maxbytes must be a positive integer"));
  441. else
  442. maxbytes = strtol (optarg, NULL, 0);
  443. case 'q':
  444. asprintf(&server_quit, "%s\r\n", optarg);
  445. break;
  446. case 'r':
  447. if (!strncmp(optarg,"ok",2))
  448. econn_refuse_state = STATE_OK;
  449. else if (!strncmp(optarg,"warn",4))
  450. econn_refuse_state = STATE_WARNING;
  451. else if (!strncmp(optarg,"crit",4))
  452. econn_refuse_state = STATE_CRITICAL;
  453. else
  454. usage4 (_("Refuse must be one of ok, warn, crit"));
  455. break;
  456. case 'M':
  457. if (!strncmp(optarg,"ok",2))
  458. expect_mismatch_state = STATE_OK;
  459. else if (!strncmp(optarg,"warn",4))
  460. expect_mismatch_state = STATE_WARNING;
  461. else if (!strncmp(optarg,"crit",4))
  462. expect_mismatch_state = STATE_CRITICAL;
  463. else
  464. usage4 (_("Mismatch must be one of ok, warn, crit"));
  465. break;
  466. case 'd':
  467. if (is_intpos (optarg))
  468. delay = atoi (optarg);
  469. else
  470. usage4 (_("Delay must be a positive integer"));
  471. break;
  472. case 'D': /* Check SSL cert validity - days 'til certificate expiration */
  473. #ifdef HAVE_SSL
  474. # ifdef USE_OPENSSL /* XXX */
  475. if (!is_intnonneg (optarg))
  476. usage2 (_("Invalid certificate expiration period"), optarg);
  477. days_till_exp = atoi (optarg);
  478. check_cert = TRUE;
  479. flags |= FLAG_SSL;
  480. break;
  481. # endif /* USE_OPENSSL */
  482. #endif
  483. /* fallthrough if we don't have ssl */
  484. case 'S':
  485. #ifdef HAVE_SSL
  486. flags |= FLAG_SSL;
  487. #else
  488. die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
  489. #endif
  490. break;
  491. }
  492. }
  493. if (server_address == NULL)
  494. usage4 (_("You must provide a server address"));
  495. else if (is_host (optarg) == FALSE && optarg[0] != '/')
  496. usage2 (_("Invalid hostname, address, or socket"), optarg);
  497. return TRUE;
  498. }
  499. void
  500. print_help (void)
  501. {
  502. print_revision (progname, revision);
  503. printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
  504. printf (COPYRIGHT, copyright, email);
  505. printf (_("This plugin tests %s connections with the specified host (or unix socket).\n\n"),
  506. SERVICE);
  507. print_usage ();
  508. printf (_(UT_HELP_VRSN));
  509. printf (_(UT_HOST_PORT), 'p', "none");
  510. printf (_(UT_IPv46));
  511. printf (_("\
  512. -s, --send=STRING\n\
  513. String to send to the server\n\
  514. -e, --expect=STRING\n\
  515. String to expect in server response\n\
  516. -q, --quit=STRING\n\
  517. String to send server to initiate a clean close of the connection\n"));
  518. printf (_("\
  519. -r, --refuse=ok|warn|crit\n\
  520. Accept tcp refusals with states ok, warn, crit (default: crit)\n\
  521. -M, --mismatch=ok|warn|crit\n\
  522. Accept expected string mismatches with states ok, warn, crit (default: warn)\n\
  523. -j, --jail\n\
  524. Hide output from TCP socket\n\
  525. -m, --maxbytes=INTEGER\n\
  526. Close connection once more than this number of bytes are received\n\
  527. -d, --delay=INTEGER\n\
  528. Seconds to wait between sending string and polling for response\n"));
  529. #ifdef HAVE_SSL
  530. printf (_("\
  531. -D, --certificate=INTEGER\n\
  532. Minimum number of days a certificate has to be valid.\n\
  533. -S, --ssl\n\
  534. Use SSL for the connection.\n"));
  535. #endif
  536. printf (_(UT_WARN_CRIT));
  537. printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
  538. printf (_(UT_VERBOSE));
  539. printf (_(UT_SUPPORT));
  540. }
  541. void
  542. print_usage (void)
  543. {
  544. printf ("\
  545. Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
  546. [-s <send string>] [-e <expect string>] [-q <quit string>]\n\
  547. [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\
  548. [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]\n\
  549. [-D <days to cert expiry>] [-S <use SSL>]\n", progname);
  550. }