Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix octoprint ssl #3718

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions lib/Slic3r/GUI/Plater.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ our $PROCESS_COMPLETED_EVENT : shared = Wx::NewEventType;
use constant FILAMENT_CHOOSERS_SPACING => 0;
use constant PROCESS_DELAY => 0.5 * 1000; # milliseconds

use Net::SSL;
$ENV{HTTPS_VERSION} = 3;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;

my $PreventListEvents = 0;

sub new {
Expand Down Expand Up @@ -262,7 +266,16 @@ sub new {

my $ua = LWP::UserAgent->new;
$ua->timeout(5);
my $res = $ua->get("http://" . $self->{config}->octoprint_host . "/api/files/local");

my $host;
if ($self->{config}->octoprint_host !~ /^http/) {
$host = "http://" . $self->{config}->octoprint_host;
}
else {
$host = $self->{config}->octoprint_host;
}

my $res = $ua->get($host . "/api/files/local");
$process_dialog->Destroy;
if ($res->is_success) {
if ($res->decoded_content =~ /"name":\s*"\Q$filename\E"/) {
Expand Down Expand Up @@ -1391,8 +1404,17 @@ sub send_gcode {
$ua->timeout(180);

my $path = Slic3r::encode_path($self->{send_gcode_file});

my $host;
if ($self->{config}->octoprint_host !~ /^http/) {
$host = "http://" . $self->{config}->octoprint_host;
}
else {
$host = $self->{config}->octoprint_host;
}

my $res = $ua->post(
"http://" . $self->{config}->octoprint_host . "/api/files/local",
$host . "/api/files/local",
Content_Type => 'form-data',
'X-Api-Key' => $self->{config}->octoprint_apikey,
Content => [
Expand Down
15 changes: 14 additions & 1 deletion lib/Slic3r/GUI/Tab.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :treectrl :wi
use Wx::Event qw(EVT_BUTTON EVT_CHOICE EVT_KEY_DOWN EVT_TREE_SEL_CHANGED);
use base qw(Wx::Panel Class::Accessor);

use Net::SSL;
$ENV{HTTPS_VERSION} = 3;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;

__PACKAGE__->mk_accessors(qw(current_preset));

sub new {
Expand Down Expand Up @@ -1226,11 +1230,20 @@ sub build {
EVT_BUTTON($self, $btn, sub {
my $ua = LWP::UserAgent->new;
$ua->timeout(10);

my $host;
if ($self->{config}->octoprint_host !~ /^http/) {
$host = "http://" . $self->{config}->octoprint_host;
}
else {
$host = $self->{config}->octoprint_host;
}

my $res = $ua->get(
"http://" . $self->{config}->octoprint_host . "/api/version",
$host . "/api/version",
'X-Api-Key' => $self->{config}->octoprint_apikey,
);

if ($res->is_success) {
Slic3r::GUI::show_info($self, "Connection to OctoPrint works correctly.", "Success!");
} else {
Expand Down