Search code examples
perlhttpswww-mechanize

Perl Mechanize bypass cert verification but encounters auth/login


im working within my company network and developing a new module for their systems. However, they have invalidated all ssl certificates thus i had to bypass the certificate verification.

Using mechanize's function to ignore ssl,

my $mech = WWW::Mechanize->new(
ssl_opts => {
    verify_hostname => 0,
},

I was able to bypass the certificate verification, however I encounter the following error Error GETing https://192.168.100.82/login;jsessionid=legizzgnfjd6g73szziuhboc: Could not resolve view with name 'auth/login' in servlet with name 'mvc'.

I do not understand whether it is it because of the unaccepted certificate that i am not able to access the https site or is it something that i had done wrong. Please help me understand what is going wrong.

the site that i am connecting to is a module's website within the company network

Here is the running of my code after initializing mechanize to ignore ssl.

my $url = 'https://192.168.100.82';
$mech->get( $url );
die $mech->response->status_line unless $mech->success;

Solution

  • I found was able to load the page successfully by controlling firefox with WWW::Mechanize::Firefox. However the downside is that it requires the firefox browser to be launched before it would be able to work.

    I used cpan to install cpanm which allows me install modules which have dependancies , it would automatically detect these dependancies and install them along with the module you selected.

    first, run install cpan (optional) , to update cpan. and refreshreload cpan.

    then install cpanm by typing install App::cpanminus and let it do its stuff.

    afterwards. close cpan and launch cpanm by typing cpanm in the cmd. Then type install WWW::Mechanize::Firefox. let it download everything completely

    Next Firefox needs Mozrepl add-on for WWW::Mechanize::Firefox to control the browser so head over to the browser and get the add-on.

    Once that is done, under tools, start MozRepl from tools tab in the browser and the script is ready to be launched.

    P.S. mechanize::firefox object is still initialized with verify_hostnames=>0