Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSL web connection

Status
Not open for further replies.

Buddyholly83

IS-IT--Management
Aug 7, 2005
23
GB
Successfully able to perform a form post using my code below. But now i need to connect to a secure webserver, however I am guessing that connecting through SSL isn't as simple as changing http -> https!
Can anyone point me in the right direction on how to make an ssl connection, I've installed Crypt::SSLeay - is this the standard class for secure connections? Is there any better ones?

Thanks in advance :)

Code:
use LWP::UserAgent;

# Make the request to the server
$userAgent = new LWP::UserAgent;
$userAgent -> timeout([10]);

my $response = $userAgent -> post($uri, 
	[
		Username => $username,
		Password => $password,
	]
);
  
# Response	
$response =  $response -> as_string;
print $response;
 
Hi,

I saw this post and thought I'd post a bit from my parsing script which parses a site that requires ssl connections. It's get so you have to convert it to post.

use LWP::UserAgent;
require HTTP::Request;

$ua = new LWP::UserAgent;
$ua->protocols_allowed( [ 'http', 'https'] );
$request = new HTTP::Request GET => "$uri";
$response = $ua->request($request);
$html=$response->as_string();

I think if you add

$userAgent->protocols_allowed( [ 'http', 'https'] );

Above your timeout call it should work.
 
So UserAgent (and effectively Crypt::SSLeay) deal with everything needed in the SSL connection (i.e certificates etc.)?

It works but part of my output says:
Code:
Client-SSL-Warning: Peer certificate not verified
Does this mean anything significant?

Thanks :)
 
It's a warning, AFAIK, it just means it can't guarantee the cert, it may be a good cert. but not issued by one of the accredited issuing authorities.

--Paul

cigless ...
 
I was surprised too, but yes. UserAgent handles Crypt::SSLeay without you needing to call it.

What's AFAIK?
 
AFAIK -> As far as I know.

When it says 'peer certificate' is it referring to me, as in the perl script accessing the service? Because in the output, the web server i am using looks like it has a valid certificate, here is the output (i've taken out the company name etc):

Code:
Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign, Inc./OU=VeriSign International Server CA - Class 3/OU=[URL unfurl="true"]www.verisign.com/CPS[/URL] Incorp.by Re
f. LIABILITY LTD.(c)97 VeriSign
Client-SSL-Cert-Subject: /C=GB/OU=Public Web/OU=Terms of use at [URL unfurl="true"]www.verisign.co.uk/rpa[/URL] (c) 03/OU=Authent
icated by VeriSign/OU=Member, VeriSign Trust Network
Client-SSL-Cipher: RC4-MD5
Client-SSL-Warning: Peer certificate not verified

Thanks again for everyone's time, it is appreciated. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top