src/CaBundle.php
public static function validateCaFile($filename, LoggerInterface $logger = null)
    {
        static $warned = false;

        if (isset(self::$caFileValidity[$filename])) {
            return self::$caFileValidity[$filename];
        }

        $contents = file_get_contents($filename);

        // assume the CA is valid if php is vulnerable to
        // https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html
        if (!static::isOpensslParseSafe()) {
            if (!$warned && $logger) {
                $logger->warning(sprintf(
                    'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
                    PHP_VERSION
                ));
                $warned = true;
            }

            $isValid = !empty($contents);
        } else {
            $isValid = (bool) openssl_x509_parse($contents);
        }

        if ($logger) {
            $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
        }

        return self::$caFileValidity[$filename] = $isValid;
    }
public static function validateCaFile($filename, LoggerInterface $logger = null)
    {
        static $warned = false;

        if (isset(self::$caFileValidity[$filename])) {
            return self::$caFileValidity[$filename];
        }

        $contents = file_get_contents($filename);

        // assume the CA is valid if php is vulnerable to
        // https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html
        if (!static::isOpensslParseSafe()) {
            if (!$warned && $logger) {
                $logger->warning(sprintf(
                    'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
                    PHP_VERSION
                ));
                $warned = true;
            }

            $isValid = !empty($contents);
        } else {
            $isValid = (bool) openssl_x509_parse($contents);
        }

        if ($logger) {
            $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
        }

        return self::$caFileValidity[$filename] = $isValid;
    }
public static function validateCaFile ( $ filename , LoggerInterface $ logger = null ) { static $ warned = false ; if ( isset ( self :: $ caFileValidity [ $ filename ] ) ) { return self :: $ caFileValidity [ $ filename ] ; } $ contents = file_get_contents ( $ filename ) ; // assume the CA is valid if php is vulnerable to // https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html if ( ! static :: isOpensslParseSafe ( ) ) { if ( ! $ warned && $ logger ) { $ logger -> warning ( sprintf ( 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.' , PHP_VERSION ) ) ; $ warned = true ; } $ isValid = ! empty ( $ contents ) ; } else { $ isValid = ( bool ) openssl_x509_parse ( $ contents ) ; } if ( $ logger ) { $ logger -> debug ( 'Checked CA file ' . realpath ( $ filename ) . ': ' . ( $ isValid ? 'valid' : 'invalid' ) ) ; } return self :: $ caFileValidity [ $ filename ] = $ isValid ; }
Validates a CA file using opensl_x509_parse only if it is safe to use

@param string          $filename
@param LoggerInterface $logger   optional logger for information about which CA files were loaded

@return bool
Validates a CA file using opensl_x509_parse only if it is safe to use