LWP::UserAgent Can't Post with TLS1.1

青春壹個敷衍的年華 提交于 2019-12-22 07:08:02

问题


Getting 500 handshaker error:443 over https. The host service I am sending XML to does not support TLS 1.2, they do support 1.0 and 1.1. Currently using LWP 6.03 on CentOS 6. Using the code below they claim I am still sending using TLS1.2

use LWP::UserAgent;
$ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0,SSL_version => 'SSLv23:!TLSv12' });
$req = HTTP::Request->new(GET => 'https://secure-host-server');

$res = $ua->request($req);
if ($res->is_success) {
  print $res->content;
  } else {
  print "Error: " . $res->status_line . "\n";
  }

Is it possible to print the TLS version as it is sent to the host? Anything I can do to verify I am using TLS1.1?


回答1:


Setting SSL_version via LWP::UserAgent would not work. I tried countless methods to try to get my code to send XML via TLSv1 without luck, The following code did the trick.

use Net::SSLGlue::LWP; 
use IO::Socket::SSL;

my $context = new IO::Socket::SSL::SSL_Context(
  SSL_version => 'tlsv1',
  SSL_verify_mode => Net::SSLeay::VERIFY_NONE(),
  );
IO::Socket::SSL::set_default_context($context);

use LWP::UserAgent;
use HTTP::Request::Common;


来源:https://stackoverflow.com/questions/20293860/lwpuseragent-cant-post-with-tls1-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!