Pavel Hlavnicka wrote:
Hi all (namely Josh :),

I need to perform some server certificate validation with LWP.

a) server cert must be issued by known CA (I have list of CA certs)
b) must not be expired
c) CN must match a server name


Sorry for not getting back to you for so long Pavel. This email got buried, and it got hectic around the holidays this year. :-( I hope my response is still helpful for you at this late date...

I do not care for CRL's.

What I can see looking into SSLeay.xs is that if environment is set
following is called:

  SSL_CTX_load_verify_locations(ctx,CAfile,CAdir);
  SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);

I tried to get some more info on these calls in openssl
documentation/source, but it was not really helpful. Could you tell me
what kind of checks is performed in such case?


I believe this just does the verification that you wanted in (a) where the server cert is being checked against known CA's.

set_verify is called in Net::SSL::connect - perhaps it should be handy,
if the callback functions might be given in some way which would be
passed into SSL_CTX_set_verify to get a better control over a validation
phase.

If you actually work with the Net::SSL interface directly, please see API example usage in script net_ssl_test in distribution, and you get get the info you need to satify checks for (b) and (c).

  my $cert = Net::SSL->new(@args)->get_peer_certificate;
  my $expires = $cert->not_after;
  my $subject = $cert->subject_name;
  my $cn = ($subject =~ /CN=[^/]+/s);

The Net::SSL interface is not formally documented however, as Crypt::SSLeay
is just being maintained to work with LWP in particular.  Maybe its time
I document this?

Regards,

Josh

________________________________________________________________________
Josh Chamas, Founder    | NodeWorks - http://www.nodeworks.com
Chamas Enterprises Inc. | NodeWorks Directory - http://dir.nodeworks.com
http://www.chamas.com   | Apache::ASP - http://www.apache-asp.org




Reply via email to