LWP::UserAgent fails on Windows to connect to https
505 <505.a7v6lb-NUepA2SMhDQqspMVqqL2D+4xXEVPTSb/[email protected]>
| Newsgroups | gmane.music.equipment.slimdevices.devel |
|---|---|
| Organization | Logitech Squeezebox Forums |
| Message-ID | <[email protected]> |
The SoundCloud plugin has a problem for Windows users. It tries to make
a connection to an https server using LWP::UserAgent. This fails with
the strange error message "500 Can't connect to api.soundcloud.com:443
()"
Here is a simplified version of the code:
Code:
--------------------
use LWP::UserAgent;
use Data::Dumper;
my $ua = LWP::UserAgent->new(
requests_redirectable => [],
);
my $res = $ua->get('https://api.soundcloud.com');
$log->debug(Dumper($res));
--------------------
This actually fails for all https servers, so it's not specific on the
SoundCloud server.
I tracked it down (I think, at least), by turning on SSL debug logging.
This gives the follow log:
Code:
--------------------
[21-09-12 14:36:51.4017] IO::Socket::SSL::DEBUG (342) Warning: DEBUG: ...>IO/Socket/SSL.pm:736: call Net::SSLeay::connect
[21-09-12 14:36:51.4028] IO::Socket::SSL::DEBUG (342) Warning: DEBUG: ...>IO/Socket/SSL.pm:739: done Net::SSLeay::connect -> 1
[21-09-12 14:36:51.4035] IO::Socket::SSL::DEBUG (342) Warning: DEBUG: ...>IO/Socket/SSL.pm:794: ssl handshake done
[21-09-12 14:36:56.0613] Plugins::SqueezeCloud::ProtocolHandler::gotNextTrack (124) https://api.soundcloud.com/tracks/1123051864/stream
[21-09-12 14:36:56.0846] IO::Socket::SSL::DEBUG (342) Warning: DEBUG: ...>IO/Socket/SSL.pm:2350: Invalid default certificate authority locations
SSL error: 10344: 1 - error:2006D002:BIO routines:BIO_new_file:system lib
SSL error: 10344: 2 - error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
[21-09-12 14:36:56.0855] IO::Socket::SSL::DEBUG (342) Warning: DEBUG: ...>IO/Socket/SSL.pm:2350: global error: Invalid default certificate authority locations error:0200107B:system library:fopen:Unknown error
[21-09-12 14:36:56.0869] Plugins::SqueezeCloud::ProtocolHandler::gotNextTrack (142) $VAR1 = {
'SSL_ca_file' => '\\Mozilla\\CA\\cacert.pem'
};
[21-09-12 14:36:56.0877] Plugins::SqueezeCloud::ProtocolHandler::gotNextTrack (143) Error: Failed to get redirect location from https://api.soundcloud.com/tracks/1123051864/stream
[21-09-12 14:36:56.0883] Plugins::SqueezeCloud::ProtocolHandler::gotNextTrack (144) 500 Can't connect to api.soundcloud.com:443 ()
[21-09-12 14:36:56.0909] IO::Socket::SSL::DEBUG (342) Warning: DEBUG: ...>IO/Socket/SSL.pm:2733: free ctx 198423064 open=198425016 198423064 198424040 198424528 198425504 104326296 104327272 104326784 104327760
[21-09-12 14:36:56.0918] IO::Socket::SSL::DEBUG (342) Warning: DEBUG: ...>IO/Socket/SSL.pm:2745: OK free ctx 198423064
--------------------
The error "Invalid default certificate authority locations" is what I
think is wrong. It occurs on Windows 10, but not on my Linux (Debian) or
MacOS machines.
BTW, the reason I'm using LWP::UserAgent and not
Slim::Networking::SimpleAsyncHTTP is that I need to get the 'Location'
header of a 302 redirect. SimpleAsyncHTTP always follows redirects and
doesn't seem to have an option to display redirects and get the data for
the 302 redirect itself.
My patch: 'Reduce brightness when screen saver is active'
(http://server.vijge.net/squeezebox/) for Touch
Plugins: 'SqueezeCloud (SoundCloud)'
(https://github.com/danielvijge/SqueezeCloud), 'Mixcloud'
(https://github.com/danielvijge/lms_mixcloud)
------------------------------------------------------------------------
505's Profile: http://forums.slimdevices.com/member.php?userid=44967
View this thread: http://forums.slimdevices.com/showthread.php?t=115130