Issue calling REST(specifically port 443) from CRON
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm having the darndest trouble trying to perform a REST call from a cron script.
My script works fine as the root user in the terminal, but when I set it up from root CRON, I get the following error:
$VAR1 = 'Can't connect to 172.16.250.159:443 (certificate verify failed)
LWP::Protocol::https::Socket: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /opt/algosec/perl5/lib/perl5/LWP/Protocol/http.pm line 51.
';
My cron looks like this:
*/5 * * * * /usr/share/fireflow/local/etc/site/lib/pending_ritm_kickoff_script.pl
My perl script runs the following:
my $client = REST::Client->new({
hostname => ''
});
my $response = '';
$client->addHeader('Content-Type', 'application/json');
my %rec_hash = (
'username' => $username,
'password' => $password,
);
my $json_body = encode_json(%rec_hash);
$client->POST("$endpoint/APP1/api/authentication/authenticate", "$json_body");
open(my $fh, '>', '/tmp/cron_report_1.txt');
print $fh Dumper($client->responseContent());
close $fh;
$response = decode_json($client->responseContent());
The client->responseContent is returning the ssl error.
But the script works fine from terminal! Any assistance is greatly appreciated.
ssl cron
add a comment |
I'm having the darndest trouble trying to perform a REST call from a cron script.
My script works fine as the root user in the terminal, but when I set it up from root CRON, I get the following error:
$VAR1 = 'Can't connect to 172.16.250.159:443 (certificate verify failed)
LWP::Protocol::https::Socket: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /opt/algosec/perl5/lib/perl5/LWP/Protocol/http.pm line 51.
';
My cron looks like this:
*/5 * * * * /usr/share/fireflow/local/etc/site/lib/pending_ritm_kickoff_script.pl
My perl script runs the following:
my $client = REST::Client->new({
hostname => ''
});
my $response = '';
$client->addHeader('Content-Type', 'application/json');
my %rec_hash = (
'username' => $username,
'password' => $password,
);
my $json_body = encode_json(%rec_hash);
$client->POST("$endpoint/APP1/api/authentication/authenticate", "$json_body");
open(my $fh, '>', '/tmp/cron_report_1.txt');
print $fh Dumper($client->responseContent());
close $fh;
$response = decode_json($client->responseContent());
The client->responseContent is returning the ssl error.
But the script works fine from terminal! Any assistance is greatly appreciated.
ssl cron
1
I don't know the first thing about perl, but you probably have something like a trusted certificate store provided by your environment, environment which wouldn't be the same when called from cron
– Aaron
Jan 4 at 14:43
Does the http cert verify with openssl, curl, wget or other program?
– Daniel Farrell
Jan 4 at 14:50
add a comment |
I'm having the darndest trouble trying to perform a REST call from a cron script.
My script works fine as the root user in the terminal, but when I set it up from root CRON, I get the following error:
$VAR1 = 'Can't connect to 172.16.250.159:443 (certificate verify failed)
LWP::Protocol::https::Socket: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /opt/algosec/perl5/lib/perl5/LWP/Protocol/http.pm line 51.
';
My cron looks like this:
*/5 * * * * /usr/share/fireflow/local/etc/site/lib/pending_ritm_kickoff_script.pl
My perl script runs the following:
my $client = REST::Client->new({
hostname => ''
});
my $response = '';
$client->addHeader('Content-Type', 'application/json');
my %rec_hash = (
'username' => $username,
'password' => $password,
);
my $json_body = encode_json(%rec_hash);
$client->POST("$endpoint/APP1/api/authentication/authenticate", "$json_body");
open(my $fh, '>', '/tmp/cron_report_1.txt');
print $fh Dumper($client->responseContent());
close $fh;
$response = decode_json($client->responseContent());
The client->responseContent is returning the ssl error.
But the script works fine from terminal! Any assistance is greatly appreciated.
ssl cron
I'm having the darndest trouble trying to perform a REST call from a cron script.
My script works fine as the root user in the terminal, but when I set it up from root CRON, I get the following error:
$VAR1 = 'Can't connect to 172.16.250.159:443 (certificate verify failed)
LWP::Protocol::https::Socket: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /opt/algosec/perl5/lib/perl5/LWP/Protocol/http.pm line 51.
';
My cron looks like this:
*/5 * * * * /usr/share/fireflow/local/etc/site/lib/pending_ritm_kickoff_script.pl
My perl script runs the following:
my $client = REST::Client->new({
hostname => ''
});
my $response = '';
$client->addHeader('Content-Type', 'application/json');
my %rec_hash = (
'username' => $username,
'password' => $password,
);
my $json_body = encode_json(%rec_hash);
$client->POST("$endpoint/APP1/api/authentication/authenticate", "$json_body");
open(my $fh, '>', '/tmp/cron_report_1.txt');
print $fh Dumper($client->responseContent());
close $fh;
$response = decode_json($client->responseContent());
The client->responseContent is returning the ssl error.
But the script works fine from terminal! Any assistance is greatly appreciated.
ssl cron
ssl cron
asked Jan 4 at 14:39
Ryan GriffinRyan Griffin
28218
28218
1
I don't know the first thing about perl, but you probably have something like a trusted certificate store provided by your environment, environment which wouldn't be the same when called from cron
– Aaron
Jan 4 at 14:43
Does the http cert verify with openssl, curl, wget or other program?
– Daniel Farrell
Jan 4 at 14:50
add a comment |
1
I don't know the first thing about perl, but you probably have something like a trusted certificate store provided by your environment, environment which wouldn't be the same when called from cron
– Aaron
Jan 4 at 14:43
Does the http cert verify with openssl, curl, wget or other program?
– Daniel Farrell
Jan 4 at 14:50
1
1
I don't know the first thing about perl, but you probably have something like a trusted certificate store provided by your environment, environment which wouldn't be the same when called from cron
– Aaron
Jan 4 at 14:43
I don't know the first thing about perl, but you probably have something like a trusted certificate store provided by your environment, environment which wouldn't be the same when called from cron
– Aaron
Jan 4 at 14:43
Does the http cert verify with openssl, curl, wget or other program?
– Daniel Farrell
Jan 4 at 14:50
Does the http cert verify with openssl, curl, wget or other program?
– Daniel Farrell
Jan 4 at 14:50
add a comment |
1 Answer
1
active
oldest
votes
The solution ended up being to add an Environment variable to the Perl Script, ignoring the SSL validation:
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54041058%2fissue-calling-restspecifically-port-443-from-cron%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The solution ended up being to add an Environment variable to the Perl Script, ignoring the SSL validation:
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
add a comment |
The solution ended up being to add an Environment variable to the Perl Script, ignoring the SSL validation:
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
add a comment |
The solution ended up being to add an Environment variable to the Perl Script, ignoring the SSL validation:
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
The solution ended up being to add an Environment variable to the Perl Script, ignoring the SSL validation:
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
answered Jan 4 at 16:10
Ryan GriffinRyan Griffin
28218
28218
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54041058%2fissue-calling-restspecifically-port-443-from-cron%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I don't know the first thing about perl, but you probably have something like a trusted certificate store provided by your environment, environment which wouldn't be the same when called from cron
– Aaron
Jan 4 at 14:43
Does the http cert verify with openssl, curl, wget or other program?
– Daniel Farrell
Jan 4 at 14:50