From c53dae4b72960c7d160afe5f762979d9d1157295 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 14 Sep 2017 16:43:41 -0700 Subject: [PATCH] Possible fix for #3919 - allow later versions of mcrypted base64 keys --- app/Console/Commands/RecryptFromMcrypt.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/RecryptFromMcrypt.php b/app/Console/Commands/RecryptFromMcrypt.php index 6c340e2df7..7437708207 100644 --- a/app/Console/Commands/RecryptFromMcrypt.php +++ b/app/Console/Commands/RecryptFromMcrypt.php @@ -47,6 +47,7 @@ class RecryptFromMcrypt extends Command // Check and see if they have a legacy app key listed in their .env // If not, we can try to use the current APP_KEY if looks like it's old $legacy_key = env('LEGACY_APP_KEY'); + $key_parts = explode(':', $legacy_key); $errors = array(); if (!$legacy_key) { @@ -54,11 +55,23 @@ class RecryptFromMcrypt extends Command return false; } - // Check that the app key is 32 characters + + // Do some basic legacy app key length checks if (strlen($legacy_key) == 32) { - $this->comment('INFO: Your LEGACY_APP_KEY is 32 characters. Okay to continue.'); + $legacy_length_check = true; + } elseif (array_key_exists('1', $key_parts) && (strlen($key_parts[1])==44)) { + $legacy_length_check = true; } else { - $this->error('ERROR: Your LEGACY_APP_KEY is not the correct length (32 characters). Please locate your old APP_KEY and use that as your LEGACY_APP_KEY in your .env file to continue.'); + $legacy_length_check = false; + } + + + + // Check that the app key is 32 characters + if ($legacy_length_check === true) { + $this->comment('INFO: Your LEGACY_APP_KEY looks correct. Okay to continue.'); + } else { + $this->error('ERROR: Your LEGACY_APP_KEY is not the correct length (32 characters or base64 followed by 44 characters for later versions). Please locate your old APP_KEY and use that as your LEGACY_APP_KEY in your .env file to continue.'); return false; }