OctoPrint upload: ignore certificate revocation checks

Fixes Hostname incorrect While test is positive (Bonjour discovery not
supported for the address field) #1781
(partial fix of #1781)
This commit is contained in:
Vojtech Bubnik 2021-08-24 11:24:48 +02:00
parent 0b654e1518
commit 6b03b66167
7 changed files with 35 additions and 3 deletions

View file

@ -491,6 +491,14 @@ Http& Http::form_add_file(const std::string &name, const fs::path &path, const s
return *this;
}
Http& Http::revoke_best_effort(bool set)
{
if(p && set){
::curl_easy_setopt(p->curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_REVOKE_BEST_EFFORT);
}
return *this;
}
Http& Http::set_post_body(const fs::path &path)
{
if (p) { p->set_post_body(path);}

View file

@ -80,6 +80,8 @@ public:
// Same as above except also override the file's filename with a custom one
Http& form_add_file(const std::string &name, const boost::filesystem::path &path, const std::string &filename);
Http& revoke_best_effort(bool set);
// Set the file contents as a POST request body.
// The data is used verbatim, it is not additionally encoded in any way.
// This can be used for hosts which do not support multipart requests.

View file

@ -25,7 +25,8 @@ namespace Slic3r {
OctoPrint::OctoPrint(DynamicPrintConfig *config) :
host(config->opt_string("print_host")),
apikey(config->opt_string("printhost_apikey")),
cafile(config->opt_string("printhost_cafile"))
cafile(config->opt_string("printhost_cafile")),
ignore_checks(config->opt_bool("printhost_ignore_check"))
{}
const char* OctoPrint::get_name() const { return "OctoPrint"; }
@ -73,6 +74,9 @@ bool OctoPrint::test(wxString &msg) const
msg = "Could not parse server response";
}
})
#ifdef WIN32
.revoke_best_effort(ignore_checks)
#endif
.perform_sync();
return res;
@ -137,6 +141,9 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
res = false;
}
})
#ifdef WIN32
.revoke_best_effort(ignore_checks)
#endif
.perform_sync();
return res;

View file

@ -40,6 +40,7 @@ private:
std::string host;
std::string apikey;
std::string cafile;
bool ignore_checks;
virtual void set_auth(Http &http) const;
std::string make_url(const std::string &path) const;