X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=openssl.c;h=15166dac0a5f1d32d7c19a27c6981399ba7fa271;hp=b3d83a77dfd5698d81de169af25b02fe45383356;hb=e52674334610f4c2a1eb22b095c126527705f314;hpb=3b674b95e412faea99dd4ff7cd84c6f7497acd30 diff --git a/openssl.c b/openssl.c index b3d83a77..15166dac 100644 --- a/openssl.c +++ b/openssl.c @@ -308,7 +308,7 @@ static int ssl_store_cert(struct client_state *csp, X509* crt) */ if (!PEM_write_bio_X509(bio, crt)) { - log_ssl_errors(LOG_LEVEL_ERROR, "PEM_write_X509() failed"); + log_ssl_errors(LOG_LEVEL_ERROR, "PEM_write_bio_X509() failed"); ret = -1; goto exit; } @@ -697,7 +697,7 @@ exit: * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) * - * Returns : 1 => Error while creating hash + * Returns : -1 => Error while creating hash * 0 => Hash created successfully * *********************************************************************/ @@ -1764,6 +1764,15 @@ static int generate_host_certificate(struct client_state *csp) return -1; } + if (enforce_sane_certificate_state(cert_opt.output_file, + cert_opt.subject_key)) + { + freez(cert_opt.output_file); + freez(cert_opt.subject_key); + + return -1; + } + if (file_exists(cert_opt.output_file) == 1) { /* The file exists, but is it valid? */ @@ -1802,25 +1811,6 @@ static int generate_host_certificate(struct client_state *csp) } } - if (file_exists(cert_opt.output_file) == 0 && - file_exists(cert_opt.subject_key) == 1) - { - log_error(LOG_LEVEL_ERROR, - "A website key already exists but there's no matching certificate. " - "Removing %s before creating a new key and certificate.", - cert_opt.subject_key); - if (unlink(cert_opt.subject_key)) - { - log_error(LOG_LEVEL_ERROR, "Failed to unlink %s: %E", - cert_opt.subject_key); - - freez(cert_opt.output_file); - freez(cert_opt.subject_key); - - return -1; - } - } - /* * Create key for requested host */