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