diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 6386fd3fe..0fa8b1d65 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -1458,11 +1458,12 @@ public static function extractBER($str) * subject=/O=organization/OU=org unit/CN=common name * issuer=/O=organization/CN=common name */ + $temp = strlen($str) <= ini_get('pcre.backtrack_limit') ? preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1) : $str; // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff - $temp = preg_replace('#-+[^-]+-+#', '', $temp); + $temp = preg_replace('#-+[^-]+-+#', '', $str); // remove new lines $temp = str_replace(["\r", "\n", ' '], '', $temp); $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? Base64::decode($temp) : false;