diff --git a/FHEM/82_LGTV_WebOS.pm b/FHEM/82_LGTV_WebOS.pm index f1aa219..1967a60 100644 --- a/FHEM/82_LGTV_WebOS.pm +++ b/FHEM/82_LGTV_WebOS.pm @@ -7,6 +7,7 @@ # # Special thanks goes to comitters: # - Vitolinker / Commandref +# - ska- / SSL_startHandshake - SSL Port 3001 Support # # # This script is free software; you can redistribute it and/or modify diff --git a/controls_LGTV_WebOS.txt b/controls_LGTV_WebOS.txt index 3e08321..9fee12c 100644 --- a/controls_LGTV_WebOS.txt +++ b/controls_LGTV_WebOS.txt @@ -1,2 +1,2 @@ -UPD 2023-05-16_04:16:05 18968 FHEM/82_LGTV_WebOS.pm -UPD 2023-05-16_04:14:37 55512 lib/FHEM/Devices/LGTV/LGTVWebOS.pm +UPD 2023-11-15_19:19:41 19028 FHEM/82_LGTV_WebOS.pm +UPD 2023-11-17_18:00:13 56133 lib/FHEM/Devices/LGTV/LGTVWebOS.pm diff --git a/lib/FHEM/Devices/LGTV/LGTVWebOS.pm b/lib/FHEM/Devices/LGTV/LGTVWebOS.pm index e8cd3c2..11bac57 100644 --- a/lib/FHEM/Devices/LGTV/LGTVWebOS.pm +++ b/lib/FHEM/Devices/LGTV/LGTVWebOS.pm @@ -61,6 +61,7 @@ my $missingModul = ""; eval { require MIME::Base64; 1 } or $missingModul .= 'MIME::Base64 '; eval { require IO::Socket::INET; 1 } or $missingModul .= 'IO::Socket::INET '; +eval { use IO::Socket::SSL; 1 } or $missingModul .= 'IO::Socket::SSL '; ## no critic (Conditional "use" statement. Use "require" to conditionally include a module (Modules::ProhibitConditionalUseStatements)) eval { use Digest::SHA qw /sha1_hex/; 1 } or $missingModul .= 'Digest::SHA '; @@ -648,7 +649,21 @@ sub Open { ::Log3( $name, 4, "LGTV_WebOS ($name) - Baue Socket Verbindung auf" ); - my $socket = IO::Socket::INET->new( + # create a connecting socket + # SSL_startHandshake is dependent on the protocol: this lets us use one socket + # to work with either SSL or non-SSL sockets. + my $socket = IO::Socket::SSL->new( + PeerHost => $host, + PeerPort => 3001, + Proto => 'tcp', + SSL_startHandshake => 1, #( $proto eq 'wss' ? 1 : 0 ), + SSL_verify_mode => SSL_VERIFY_NONE, + + # Blocking => 1 + KeepAlive => 1, + Timeout => $timeout + ) + || IO::Socket::INET->new( PeerHost => $host, PeerPort => $port, Proto => 'tcp', @@ -656,7 +671,8 @@ sub Open { Timeout => $timeout ) or return ::Log3( $name, 4, - "LGTV_WebOS ($name) Couldn't connect to $host:$port" ); # open Socket + "LGTV_WebOS ($name) Couldn't connect to $host:$port/3001" ) + ; # open Socket $hash->{FD} = $socket->fileno(); $hash->{CD} = $socket; # sysread / close won't work on fileno