SSLClient Authentification: Unterschied zwischen den Versionen

Aus crazylinux.de
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
(added links)
 
Zeile 36: Zeile 36:
</pre>
</pre>


=Links=
http://cpan.uwinnipeg.ca/htdocs/libwww-perl/LWP/UserAgent.html<br>
http://cpan.uwinnipeg.ca/htdocs/libwww-perl/HTTP/Response.html<br>
http://www.gridsite.org/wiki/Perl_Clients<br>
http://search.cpan.org/~dland/Crypt-SSLeay-0.53_02/SSLeay.pm<br>




[[Category: Tips_und_Tricks]]
[[Category: Tips_und_Tricks]]

Aktuelle Version vom 5. März 2007, 12:30 Uhr

Per Perl mittels SSL-Client-Certifikat an einer Webseite anmelden:

#!/usr/bin/perl
use IO::Socket::SSL;#  qw(debug4);

$host = "www.server.tld";
$port = 443;
$url = "/login";
$client_cert ="client.pem";
$client_key ="client_key.pem";
$key_passwd = "client_passwd";

my $client = new IO::Socket::SSL(SSL_use_cert => 1,
	#SSL_verify_mode => 0x01,
	SSL_cert_file => $client_cert,
	SSL_key_file => $client_key,
	SSL_passwd_cb => sub { return ($key_passwd)},
	#SSL_ca_file => $trusted_ca_file,
	#SSL_ca_path => $trusted_ca_path,
	PeerAddr => $host,
	PeerPort => $port,
	Proto => 'tcp',
	Timeout => '5'
);


if ($client) {
	print $client "GET $url HTTP/1.0\r\n\r\n";
	print <$client>;
	close $client;
} else {
	warn "I encountered a problem: ",
	IO::Socket::SSL::errstr();
}

Links

http://cpan.uwinnipeg.ca/htdocs/libwww-perl/LWP/UserAgent.html
http://cpan.uwinnipeg.ca/htdocs/libwww-perl/HTTP/Response.html
http://www.gridsite.org/wiki/Perl_Clients
http://search.cpan.org/~dland/Crypt-SSLeay-0.53_02/SSLeay.pm