Skip to content

Instantly share code, notes, and snippets.

@marcelsud
Last active February 15, 2017 00:09
Show Gist options
  • Save marcelsud/2149d12a505259e00580309b88b9fd9e to your computer and use it in GitHub Desktop.
Save marcelsud/2149d12a505259e00580309b88b9fd9e to your computer and use it in GitHub Desktop.
A simple snippet to check the TLS version and ciphers for Realex (https://www.realexpayments.com/support/tls-faq/)
<?php
$recommendedCiphers = [
'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384',
'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384',
];
$supportedCiphers = [
'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256',
'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256',
'TLS_RSA_WITH_AES_256_GCM_SHA384',
'TLS_RSA_WITH_AES_128_GCM_SHA256',
];
$ch = curl_init('https://www.howsmyssl.com/a/check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$responseData = curl_exec($ch);
curl_close($ch);
$response = json_decode($responseData);
echo 'TLS version: ' . $response->tls_version . PHP_EOL . PHP_EOL;
echo 'Recommended Ciphers status:' . PHP_EOL;
foreach ($recommendedCiphers as $recommendedCipher) {
if (in_array($recommendedCipher, $response->given_cipher_suites)) {
echo ' -> ' . $recommendedCipher . ' - supported' . PHP_EOL;
continue;
}
echo ' -> ' . $recommendedCipher . ' - not supported' . PHP_EOL;
}
echo PHP_EOL;
echo 'Supported Ciphers status:' . PHP_EOL;
foreach ($supportedCiphers as $supportedCipher) {
if (in_array($supportedCipher, $response->given_cipher_suites)) {
echo ' -> ' . $supportedCipher . ' - supported' . PHP_EOL;
continue;
}
echo ' -> ' . $supportedCipher . ' - not supported' . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment