From 28ffd3d30de62be3797b197cad03b0b3f925a11d Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 17 Apr 2012 21:16:18 +0000 Subject: [PATCH] Backport change from 2.8 for Client.pm to be more resiliant to SSL negotiation delays git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@12257 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Client.pm | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index dceb2e141..08dbaa64b 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -158,22 +158,41 @@ $request->{clienttype}->[0] = "cli"; # setup clienttype for auditlog if ($ENV{XCATHOST}) { $xcathost=$ENV{XCATHOST}; } - my $client; - if (-r $keyfile and -r $certfile and -r $cafile) { - $client = IO::Socket::SSL->new( + my $pclient; + if ($inet6support) { + $pclient = IO::Socket::INET6->new( PeerAddr => $xcathost, - SSL_key_file => $keyfile, - SSL_cert_file => $certfile, - SSL_ca_file => $cafile, - SSL_use_cert => 1, Timeout => 15, ); } else { - $client = IO::Socket::SSL->new( + $pclient = IO::Socket::INET->new( PeerAddr => $xcathost, Timeout => 15, ); } + unless ($pclient) { + print "Unable to open socket connection to xcatd daemon on $xcathost.\n"; + print "Verify that the xcatd daemon is running and that your SSL setup is correct.\n"; + if ($@ =~ /SSL Timeout/) { + die "Connection failure: SSL Timeout or incorrect certificates in ~/.xcat"; + } else { + die "Connection failure: $@" + } + } + my $client; + if (-r $keyfile and -r $certfile and -r $cafile) { + $client = IO::Socket::SSL->start_SSL($pclient, + SSL_key_file => $keyfile, + SSL_cert_file => $certfile, + SSL_ca_file => $cafile, + SSL_use_cert => 1, + Timeout => 0, + ); + } else { + $client = IO::Socket::SSL->start_SSL($pclient, + Timeout => 0, + ); + } unless ($client) { print "Unable to open socket connection to xcatd daemon on $xcathost.\n"; print "Verify that the xcatd daemon is running and that your SSL setup is correct.\n"; @@ -183,6 +202,7 @@ $request->{clienttype}->[0] = "cli"; # setup clienttype for auditlog die "Connection failure: $@" } } + my $msg=XMLout($request,RootName=>'xcatrequest',NoAttr=>1,KeyAttr=>[]); if ($ENV{XCATXMLTRACE}) { print $msg; } if($ENV{XCATXMLWARNING}) {