diff options
Diffstat (limited to 'plugins/sslutils.c')
| -rw-r--r-- | plugins/sslutils.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index c58a35ab..c4ab6a05 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
| @@ -127,7 +127,7 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int | |||
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | if (cert && privkey) { | 129 | if (cert && privkey) { |
| 130 | # ifdef USE_OPENSSL | 130 | # ifdef MOPL_USE_OPENSSL |
| 131 | if (!SSL_CTX_use_certificate_chain_file(ctx, cert)) { | 131 | if (!SSL_CTX_use_certificate_chain_file(ctx, cert)) { |
| 132 | # elif USE_GNUTLS | 132 | # elif USE_GNUTLS |
| 133 | if (!SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM)) { | 133 | if (!SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM)) { |
| @@ -138,7 +138,7 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int | |||
| 138 | return STATE_CRITICAL; | 138 | return STATE_CRITICAL; |
| 139 | } | 139 | } |
| 140 | SSL_CTX_use_PrivateKey_file(ctx, privkey, SSL_FILETYPE_PEM); | 140 | SSL_CTX_use_PrivateKey_file(ctx, privkey, SSL_FILETYPE_PEM); |
| 141 | # ifdef USE_OPENSSL | 141 | # ifdef MOPL_USE_OPENSSL |
| 142 | if (!SSL_CTX_check_private_key(ctx)) { | 142 | if (!SSL_CTX_check_private_key(ctx)) { |
| 143 | printf("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n")); | 143 | printf("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n")); |
| 144 | return STATE_CRITICAL; | 144 | return STATE_CRITICAL; |
| @@ -161,9 +161,9 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int | |||
| 161 | return OK; | 161 | return OK; |
| 162 | } else { | 162 | } else { |
| 163 | printf("%s\n", _("CRITICAL - Cannot make SSL connection.")); | 163 | printf("%s\n", _("CRITICAL - Cannot make SSL connection.")); |
| 164 | # ifdef USE_OPENSSL /* XXX look into ERR_error_string */ | 164 | # ifdef MOPL_USE_OPENSSL /* XXX look into ERR_error_string */ |
| 165 | ERR_print_errors_fp(stdout); | 165 | ERR_print_errors_fp(stdout); |
| 166 | # endif /* USE_OPENSSL */ | 166 | # endif /* MOPL_USE_OPENSSL */ |
| 167 | } | 167 | } |
| 168 | } else { | 168 | } else { |
| 169 | printf("%s\n", _("CRITICAL - Cannot initiate SSL handshake.")); | 169 | printf("%s\n", _("CRITICAL - Cannot initiate SSL handshake.")); |
| @@ -192,7 +192,7 @@ int np_net_ssl_read(void *buf, int num) { return SSL_read(s, buf, num); } | |||
| 192 | 192 | ||
| 193 | mp_state_enum np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, | 193 | mp_state_enum np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, |
| 194 | int days_till_exp_crit) { | 194 | int days_till_exp_crit) { |
| 195 | # ifdef USE_OPENSSL | 195 | # ifdef MOPL_USE_OPENSSL |
| 196 | if (!certificate) { | 196 | if (!certificate) { |
| 197 | printf("%s\n", _("CRITICAL - No server certificate present to inspect.")); | 197 | printf("%s\n", _("CRITICAL - No server certificate present to inspect.")); |
| 198 | return STATE_CRITICAL; | 198 | return STATE_CRITICAL; |
| @@ -306,14 +306,14 @@ mp_state_enum np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_ | |||
| 306 | } | 306 | } |
| 307 | X509_free(certificate); | 307 | X509_free(certificate); |
| 308 | return status; | 308 | return status; |
| 309 | # else /* ifndef USE_OPENSSL */ | 309 | # else /* ifndef MOPL_USE_OPENSSL */ |
| 310 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); | 310 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); |
| 311 | return STATE_WARNING; | 311 | return STATE_WARNING; |
| 312 | # endif /* USE_OPENSSL */ | 312 | # endif /* MOPL_USE_OPENSSL */ |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | retrieve_expiration_time_result np_net_ssl_get_cert_expiration(X509 *certificate) { | 315 | retrieve_expiration_time_result np_net_ssl_get_cert_expiration(X509 *certificate) { |
| 316 | # ifdef USE_OPENSSL | 316 | # ifdef MOPL_USE_OPENSSL |
| 317 | retrieve_expiration_time_result result = { | 317 | retrieve_expiration_time_result result = { |
| 318 | .errors = ALL_OK, | 318 | .errors = ALL_OK, |
| 319 | .remaining_seconds = 0, | 319 | .remaining_seconds = 0, |
| @@ -404,14 +404,14 @@ retrieve_expiration_time_result np_net_ssl_get_cert_expiration(X509 *certificate | |||
| 404 | X509_free(certificate); | 404 | X509_free(certificate); |
| 405 | 405 | ||
| 406 | return result; | 406 | return result; |
| 407 | # else /* ifndef USE_OPENSSL */ | 407 | # else /* ifndef MOPL_USE_OPENSSL */ |
| 408 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); | 408 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); |
| 409 | return STATE_WARNING; | 409 | return STATE_WARNING; |
| 410 | # endif /* USE_OPENSSL */ | 410 | # endif /* MOPL_USE_OPENSSL */ |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | net_ssl_check_cert_result np_net_ssl_check_cert2(int days_till_exp_warn, int days_till_exp_crit) { | 413 | net_ssl_check_cert_result np_net_ssl_check_cert2(int days_till_exp_warn, int days_till_exp_crit) { |
| 414 | # ifdef USE_OPENSSL | 414 | # ifdef MOPL_USE_OPENSSL |
| 415 | X509 *certificate = NULL; | 415 | X509 *certificate = NULL; |
| 416 | certificate = SSL_get_peer_certificate(s); | 416 | certificate = SSL_get_peer_certificate(s); |
| 417 | 417 | ||
| @@ -438,27 +438,27 @@ net_ssl_check_cert_result np_net_ssl_check_cert2(int days_till_exp_warn, int day | |||
| 438 | 438 | ||
| 439 | return result; | 439 | return result; |
| 440 | 440 | ||
| 441 | # else /* ifndef USE_OPENSSL */ | 441 | # else /* ifndef MOPL_USE_OPENSSL */ |
| 442 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); | 442 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); |
| 443 | return STATE_WARNING; | 443 | return STATE_WARNING; |
| 444 | # endif /* USE_OPENSSL */ | 444 | # endif /* MOPL_USE_OPENSSL */ |
| 445 | } | 445 | } |
| 446 | 446 | ||
| 447 | mp_state_enum np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit) { | 447 | mp_state_enum np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit) { |
| 448 | # ifdef USE_OPENSSL | 448 | # ifdef MOPL_USE_OPENSSL |
| 449 | X509 *certificate = NULL; | 449 | X509 *certificate = NULL; |
| 450 | certificate = SSL_get_peer_certificate(s); | 450 | certificate = SSL_get_peer_certificate(s); |
| 451 | return (np_net_ssl_check_certificate(certificate, days_till_exp_warn, days_till_exp_crit)); | 451 | return (np_net_ssl_check_certificate(certificate, days_till_exp_warn, days_till_exp_crit)); |
| 452 | # else /* ifndef USE_OPENSSL */ | 452 | # else /* ifndef MOPL_USE_OPENSSL */ |
| 453 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); | 453 | printf("%s\n", _("WARNING - Plugin does not support checking certificates.")); |
| 454 | return STATE_WARNING; | 454 | return STATE_WARNING; |
| 455 | # endif /* USE_OPENSSL */ | 455 | # endif /* MOPL_USE_OPENSSL */ |
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | mp_subcheck mp_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, | 458 | mp_subcheck mp_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, |
| 459 | int days_till_exp_crit) { | 459 | int days_till_exp_crit) { |
| 460 | mp_subcheck sc_cert = mp_subcheck_init(); | 460 | mp_subcheck sc_cert = mp_subcheck_init(); |
| 461 | # ifdef USE_OPENSSL | 461 | # ifdef MOPL_USE_OPENSSL |
| 462 | if (!certificate) { | 462 | if (!certificate) { |
| 463 | xasprintf(&sc_cert.output, _("No server certificate present to inspect")); | 463 | xasprintf(&sc_cert.output, _("No server certificate present to inspect")); |
| 464 | sc_cert = mp_set_subcheck_state(sc_cert, STATE_CRITICAL); | 464 | sc_cert = mp_set_subcheck_state(sc_cert, STATE_CRITICAL); |
| @@ -581,10 +581,10 @@ mp_subcheck mp_net_ssl_check_certificate(X509 *certificate, int days_till_exp_wa | |||
| 581 | } | 581 | } |
| 582 | X509_free(certificate); | 582 | X509_free(certificate); |
| 583 | return sc_cert; | 583 | return sc_cert; |
| 584 | # else /* ifndef USE_OPENSSL */ | 584 | # else /* ifndef MOPL_USE_OPENSSL */ |
| 585 | xasprintf(&sc_cert.output, _("Plugin does not support checking certificates")); | 585 | xasprintf(&sc_cert.output, _("Plugin does not support checking certificates")); |
| 586 | sc_cert = mp_set_subcheck_state(sc_cert, STATE_WARNING); | 586 | sc_cert = mp_set_subcheck_state(sc_cert, STATE_WARNING); |
| 587 | return sc_cert; | 587 | return sc_cert; |
| 588 | # endif /* USE_OPENSSL */ | 588 | # endif /* MOPL_USE_OPENSSL */ |
| 589 | } | 589 | } |
| 590 | #endif /* HAVE_SSL */ | 590 | #endif /* HAVE_SSL */ |
