summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorRemy <relst@relst.nl>2015-04-12 15:14:25 +0200
committerRemy <relst@relst.nl>2015-04-12 15:14:25 +0200
commita7690e83a90a9e68c4bc74bf03f8b50d2261377c (patch)
tree27a2c55e9b300fc1641a768ae34e8cc5d024016b /functions
parent225ba54913c49cfeca7e3afa7d2e9af128a344a7 (diff)
downloadssl-decoder-a7690e83a90a9e68c4bc74bf03f8b50d2261377c.zip
ssl-decoder-a7690e83a90a9e68c4bc74bf03f8b50d2261377c.tar.gz
ssl-decoder-a7690e83a90a9e68c4bc74bf03f8b50d2261377c.tar.bz2
fix long duration and possible timeout of non-http/s tests
Diffstat (limited to 'functions')
-rw-r--r--functions/connection.php19
-rw-r--r--functions/json.php4
-rw-r--r--functions/variables.php1
3 files changed, 21 insertions, 3 deletions
diff --git a/functions/connection.php b/functions/connection.php
index d6d1391..0ab8e7c 100644
--- a/functions/connection.php
+++ b/functions/connection.php
@@ -28,6 +28,22 @@ function get(&$var, $default=null) {
}
function server_http_headers($host, $port){
+ // first check if server is http. otherwise long timeout.
+ $ch = curl_init(("https://" . $host . ":" . $port));
+ curl_setopt($ch, CURLOPT_TIMEOUT, 2);
+ curl_setopt($ch, CURLOPT_NOBODY, true);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_FAILONERROR, true);
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ if(curl_exec($ch) === false) {
+ curl_close($ch);
+ return false;
+ }
+ curl_close($ch);
+
stream_context_set_default(
array("ssl" =>
array("verify_peer" => false,
@@ -37,7 +53,8 @@ function server_http_headers($host, $port){
"sni_enabled" => true),
'http' => array(
'method' => 'GET',
- 'max_redirects' => 1
+ 'max_redirects' => 1,
+ 'timeout' => 2
)
)
);
diff --git a/functions/json.php b/functions/json.php
index 26058a6..8e6dc97 100644
--- a/functions/json.php
+++ b/functions/json.php
@@ -45,9 +45,9 @@ function check_json($host,$port) {
$chain_key = (string)$key+1;
if ($key == 0) {
$data["connection"] = ssl_conn_metadata_json($host, $port, $read_stream, $chain_data);
- $data["chain"][$chain_key] = cert_parse_json($curr, $next, $host, true);
+ //$data["chain"][$chain_key] = cert_parse_json($curr, $next, $host, true);
} else {
- $data["chain"][$chain_key] = cert_parse_json($curr, $next, null, false);
+ //$data["chain"][$chain_key] = cert_parse_json($curr, $next, null, false);
}
}
} else {
diff --git a/functions/variables.php b/functions/variables.php
index c578bed..6869f71 100644
--- a/functions/variables.php
+++ b/functions/variables.php
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
date_default_timezone_set('UTC');
+ini_set('default_socket_timeout', 2);
$version = 2.2;