PHP code example of pantheon-systems / drupal_tls_checker
1. Go to this page and download the library: Download pantheon-systems/drupal_tls_checker library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pantheon-systems / drupal_tls_checker example snippets
namespace Drupal\tls_checker_test\Service;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
/**
* Service to test TLS requests.
*/
class TLSCheckerTestService {
/**
* Performs a request against a known bad TLS URL.
*/
public function testTLSRequest() {
$client = new Client([
'verify' => TRUE, // Enforce TLS certificate verification
'timeout' => 5,
]);
try {
$response = $client->get('https://tls-v1-1.badssl.com:1011/');
return [
'status' => 'success',
'code' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
];
}
catch (RequestException $e) {
return [
'status' => 'error',
'message' => $e->getMessage(),
];
}
}
}