mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
HttpUtils.pm: nonblocking start_SSL handling NON-HTTPS ports (Forum #125939)
git-svn-id: https://svn.fhem.de/fhem/trunk@25623 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8dd07d046d
commit
4b3755ef9a
@ -494,10 +494,12 @@ HttpUtils_Connect2NonblockingSSL($$)
|
||||
|
||||
$hash->{conn}->blocking(0);
|
||||
$par->{SSL_startHandshake} = 0;
|
||||
IO::Socket::SSL->start_SSL($hash->{conn}, $par);
|
||||
if($hash->{conn}->connect_SSL && $! != EWOULDBLOCK) {
|
||||
if(!IO::Socket::SSL->start_SSL($hash->{conn}, $par) ||
|
||||
$hash->{conn}->connect_SSL() ||
|
||||
$! != EWOULDBLOCK) {
|
||||
HttpUtils_Close($hash);
|
||||
return $hash->{callback}($hash, $!);
|
||||
return $hash->{callback}($hash,
|
||||
"$! ".($SSL_ERROR ? $SSL_ERROR : IO::Socket::SSL::errstr()));
|
||||
}
|
||||
|
||||
$hash->{FD} = $hash->{conn}->fileno();
|
||||
@ -507,20 +509,21 @@ HttpUtils_Connect2NonblockingSSL($$)
|
||||
"HttpUtils_TimeoutErr", \%timerHash);
|
||||
|
||||
$hash->{directReadFn} = sub() {
|
||||
return if(!$hash->{conn}->connect_SSL);
|
||||
return if(!$hash->{conn}->connect_SSL() && $! == EWOULDBLOCK);
|
||||
|
||||
RemoveInternalTimer(\%timerHash);
|
||||
delete($hash->{FD});
|
||||
delete($hash->{directReadFn});
|
||||
delete($selectlist{$hash});
|
||||
|
||||
if($!) {
|
||||
if($! || $SSL_ERROR) {
|
||||
HttpUtils_Close($hash);
|
||||
return $hash->{callback}($hash, $!);
|
||||
return $hash->{callback}($hash,
|
||||
"$! ".($SSL_ERROR ? $SSL_ERROR : IO::Socket::SSL::errstr()));
|
||||
}
|
||||
|
||||
$hash->{hu_sslAdded} = 1;
|
||||
return HttpUtils_Connect2($hash); # Continue with HTTP
|
||||
return HttpUtils_Connect2($hash); # Continue with HTML-Processing
|
||||
};
|
||||
|
||||
return undef;
|
||||
@ -573,7 +576,7 @@ HttpUtils_Connect2($)
|
||||
if(!$hash->{sslargs} || !defined($hash->{sslargs}{SSL_verify_mode}));
|
||||
|
||||
return HttpUtils_Connect2NonblockingSSL($hash,\%par)
|
||||
if($hash->{callback} && IO::Socket::SSL->can('connect_SSL'));
|
||||
if($hash->{callback});
|
||||
|
||||
eval {
|
||||
IO::Socket::SSL->start_SSL($hash->{conn}, \%par) || undef $hash->{conn};
|
||||
|
Loading…
Reference in New Issue
Block a user