+sub check_bad_ssl() {
+ my $failures = 0;
+ my @bad_ssl_urls_to_check = (
+ "https://expired.badssl.com/",
+ "https://wrong.host.badssl.com/",
+ "https://self-signed.badssl.com/",
+ "https://untrusted-root.badssl.com/",
+ "https://no-common-name.badssl.com/", # XXX: Certificate has expired ...
+ "https://no-subject.badssl.com/", # XXX: Certificate has expired ...
+ "https://incomplete-chain.badssl.com/",
+ );
+ # This is needed for get_status_code() to skip the
+ # status code from the "HTTP/1.1 200 Connection established"
+ # reply.
+ our $privoxy_cgi_url = "https://p.p/";
+
+ log_message("Requesting pages from badssl.com with various " .
+ "certificate problems. This will only work if Privoxy " .
+ "has been configured properly and can reach the Internet.");
+
+ foreach my $url_to_check (@bad_ssl_urls_to_check) {
+ my ($buffer_ref, $status_code);
+ log_message("Requesting $url_to_check");
+
+ $buffer_ref = get_page_with_curl($url_to_check);
+ $status_code = get_status_code($buffer_ref);
+
+ if (!check_status_code_result($status_code, "403")) {
+ $failures++;
+ }
+
+ }
+ if ($failures == 0) {
+ log_message("All requests resulted in status code 403 as expected.");
+ } else {
+ log_message("There were $failures requests that did not result in status code 403!");
+ }
+
+ return $failures;
+}
+