I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2007-06-21 07:54:58-07 by jebe86
Client cert validation fails
Hi all, probably this is stupid, but I can not "force" io::Socket::SSL to verify the client side of the connection. I know certificate s are valid, because I checked hme with openss s_server... and openss s_client, and also with a simple https server. When I try to acces the client certificates on the server, I get this: Undefined SSL objecterror:00000000:lib(0):func(0):reason(0) What am I donig wrong ? Thanks for any help ! Here are the scripts:
CLIENT use IO::Socket; use IO::Handle; use IO::Socket::SSL(debug2); ##to use crypto transfer require File::Basename; require File::Spec; if(!($sock = IO::Socket::SSL->new( PeerAddr => 'localhost', PeerPort => '9502', Proto => 'tcp', SSL_use_cert =>'1', SSL_verify_mode => '0x02', SSL_key_file => 'client-new-key.pem', SSL_cert_file => 'client-new-cert.pem', SSL_ca_file => 'CAperDT-cacert.pem' ))) { print "ERROR: unable to create socket: '$!'.\n"; exit(2); } print "connect ($sock).\n" if ($IO::Socket::SSL::DEBUG); # check server cert. my ($peer_cert, $subject_name, $issuer_name, $cipher); if( ref($sock) eq "IO::Socket::SSL") { if(($peer_cert = $sock->get_peer_certificate)) { $subject_name = $peer_cert->subject_name; $issuer_name = $peer_cert->issuer_name; $cipher = $sock->get_cipher(); } print "cipher: $cipher.\n"; print "server cert:\n". "\t '$subject_name' \n\t '$issuer_name'.\n\n"; } $stringa = "hello"; $sock->syswrite($stringa,length($stringa)); $sock->sysread($buf, 32768); $stringa = "exit"; $sock->syswrite($stringa,length($stringa)); exit(0); SERVER use File::Spec; #use strict; use IO::Socket::SSL; $Local_Host = 'localhost'; my ($sock, $s, $v_mode); if($ARGV[0] eq "DEBUG") { $IO::Socket::SSL::DEBUG = 4; } if(!($sock = IO::Socket::SSL->new( Listen => 5, LocalAddr => $Local_Host, LocalPort => 9502, Proto => 'tcp', Reuse => 1, SSL_verify_mode => 0x02, SSL_key_file => 'server-new-key.pem', SSL_cert_file => 'server-new-cert.pem', SSL_ca_file => 'CAperDT-cacert.pem', SSL_use_cert => '1', SSL_error_trap=>&culo, # SSL_ca_path => '' )) ) { print STDERR "unable to create socket: $!.\n"; exit(0); } print STDERR "socket created: $sock.\n"; open(PIDDU,">Server_DT_bbftp.pid"); PIDDU->autoflush(1); print PIDDU $$; print "PID $$\n"; close(PIDDU); while (1) { print STDERR "waiting for next connection.\n"; while(($s = $sock->accept())) { if( ! $s ) { print STDERR "SUO ERRORE error: '$!'.\n"; next; } my ($peer_cert, $subject_name, $issuer_name, $date, $str); $remote_site=$s->peerhost(); print "remote $remote_site\n"; print MAIN_LOG scalar(localtime(time()))," connection from $remote_site\n"; if (ref($sock) eq "IO::Socket::SSL") { if(($peer_cert = $sock->get_peer_certificate)) { $subject_name = $peer_cert->subject_name; $issuer_name = $peer_cert->issuer_name; $cipher = $sock->get_cipher(); } print "cipher: $cipher.\n"; print "server cert:\n". "\t '$subject_name' \n\t '$issuer_nam +e'.\n\n"; } else { print "in err $peer_cert\n"; print errstr($sock),"$SSL_ERROR AHHAHAHHAHH\n"; } while (1) { my $buf =""; $s->sysread($buf,32768); print "Read: $buf\n"; # Exit if ($buf =~ /quit|exit/i) { $s->close(); last; } } # Error else { print "Error in input\n"; $s->close(); last; } } } } $sock->close();
Direct Responses: 5498 | Write a response
Posted on 2007-06-21 09:27:23-07 by noxxi in response to 5496
Re: Client cert validation fails
Please send information about the version of IO::Socket::SSL you are using and about the operating system.
And then the code of the server you send does not compile (Syntax errors in line 70 and 76).
And then you specified that it should call a function 'culo' for getting SSL_error_trap, but I cannot find this function ('&culo' is a function call, while '\&culo' is the reference to the function)

So please send me kind of working version with all necessary files (e.g. client, server, *.pem files) so that I can reproduce the problem (you might send it directly to Steffen_Ullrich@genua.de because Attachments are not possible here)
Direct Responses: 5500 | Write a response
Posted on 2007-06-21 10:31:10-07 by jebe86 in response to 5498
Re: Client cert validation fails
Newest IO::Socket:SSL (1.0.7) and Net::SSLeay(1.30) form CPAN. Sent you "working" source code, what I posted eralier was a messy cut-and-paste.sorry for that...
Direct Responses: 5501 | Write a response
Posted on 2007-06-21 10:54:43-07 by noxxi in response to 5500
Re: Client cert validation fails

I've send you the fixed source back.

But for the record, in case somebody searches the forum for the solution:
To check the client certificate the SSL_verify_mode must *include* 0x01 and to force it to fail if no client cert it must include 0x02, which means together 0x03 (bitmasks).
The other problem was that the server checked the peer certificate on the listening socket and not on the socket connected to the client

Direct Responses: 11497 | Write a response
Posted on 2009-09-24 20:39:44-07 by afausak in response to 5501
Re: Client cert validation fails
was this solution posted? I'm having issues setting up as well. Thanks.
Direct Responses: 11498 | Write a response
Posted on 2009-09-25 18:44:15-07 by noxxi in response to 11497
Re: Client cert validation fails
the solution was posted, just look at the message preceding yours in the thread. You need to set verify_mode right.
Direct Responses: Write a response