<commit_before><?php
$ctx = stream_context_create(array('ssl' => array(
    'capture_peer_cert' => true,
    'verify_peer'       => true,
    'allow_self_signed' => false,
    'cafile'            => '/etc/pki/tls/certs/ca-bundle.crt',
    'CN_match'          => 'mxr.mozilla.org',
)));
$socket = stream_socket_client('ssl://mxr.mozilla.org:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx);
$params = stream_context_get_params($socket);
openssl_x509_export($params['options']['ssl']['peer_certificate'], $certificate);
$certificate = str_replace('-----BEGIN CERTIFICATE-----', '', $certificate);
$certificate = str_replace('-----END CERTIFICATE-----', '', $certificate);
$certificate = base64_decode($certificate);
$fingerprint = strtoupper(sha1($certificate));
$fingerprint = str_split($fingerprint, 2);
$fingerprint = implode(':', $fingerprint);
?>
<h2 style="text-align: center;">SSL SHA1 fingerprint for mxr.mozilla.org:</h2>
<pre style="text-align: center; font-size: 25px;"><?php echo $fingerprint; ?></pre>
<p style="text-align: center;">You are encouraged to <a href="https://github.com/EvanDotPro/Sslurp/blob/master/bin/mozilla-ssl-fingerprint.php">view the source of this file</a>. If you prefer additional verification, navigate to <a href="https://mxr.mozilla.org/">https://mxr.mozilla.org/</a> and view the certificate details in your own browser.</p><commit_msg>Update mozilla-ssl-fingerprint.php to try other paths for a trusted root CA bundle<commit_after><?php
// Fetch and display the mxr.mozilla.org SSL certificate SHA1 fingerprint
$caBundlePaths = array(
    '/etc/pki/tls/certs/ca-bundle.crt',
    '/etc/ssl/certs/ca-certificates.crt',
    '/etc/ssl/ca-bundle.pem',
    '/usr/share/ssl/certs/ca-bundle.crt',
);

$trustedBundle = false;
foreach ($caBundlePaths as $caBundle) {
    if (file_exists($caBundle) && is_readable($caBundle)) {
        $trustedBundle = $caBundle;
        break;
    }
}
if (!$trustedBundle) die('No trusted root CA bundle found.');

$ctx = stream_context_create(array('ssl' => array(
    'capture_peer_cert' => true,
    'verify_peer'       => true,
    'allow_self_signed' => false,
    'cafile'            => $trustedBundle,
    'CN_match'          => 'mxr.mozilla.org',
)));
$socket = stream_socket_client('ssl://mxr.mozilla.org:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx);
$params = stream_context_get_params($socket);
openssl_x509_export($params['options']['ssl']['peer_certificate'], $certificate);
$certificate = str_replace('-----BEGIN CERTIFICATE-----', '', $certificate);
$certificate = str_replace('-----END CERTIFICATE-----', '', $certificate);
$certificate = base64_decode($certificate);
$fingerprint = strtoupper(sha1($certificate));
$fingerprint = str_split($fingerprint, 2);
$fingerprint = implode(':', $fingerprint);
?>
<h2 style="text-align: center;">mxr.mozilla.org SSL certificate SHA1 fingerprint:</h2>
<pre style="text-align: center; font-size: 25px;"><?php echo $fingerprint; ?></pre>
<p style="text-align: center;">
You are encouraged to <ahref="https://github.com/EvanDotPro/Sslurp/blob/master/bin/mozilla-ssl-fingerprint.php">view
the source of this file</a>. If you prefer additional verification, navigate to
<a href="https://mxr.mozilla.org/">https://mxr.mozilla.org/</a> and view the
certificate details in your own browser.
</p>
{'fraction_non_alphanumeric': 0.1838146811070999, 'fraction_numerical': 0.0105294825511432, 'mean_word_length': 4.85387323943662, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4416585', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1095, 'n_words': 224}