diff --git a/app/code/Magento/EncryptionKey/Model/Resource/Key/Change.php b/app/code/Magento/EncryptionKey/Model/Resource/Key/Change.php
index 5ebcea5dbbb018f7a963dc2aaba364a54c26d849..171bf88a2dd57981fc964bf8e4001bea89ad1abc 100644
--- a/app/code/Magento/EncryptionKey/Model/Resource/Key/Change.php
+++ b/app/code/Magento/EncryptionKey/Model/Resource/Key/Change.php
@@ -122,9 +122,9 @@ class Change extends \Magento\Framework\Model\Resource\Db\AbstractDb
         }
 
         if (null === $key) {
-            $key = md5(
-                $this->random->getRandomString(\Magento\Setup\Model\ConfigGenerator::STORE_KEY_RANDOM_STRING_SIZE)
-            );
+            $key = md5($this->random->getRandomString(
+                \Magento\Framework\Config\ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE
+            ));
         }
         $this->encryptor->setNewKey($key);
 
diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php
index 6608cb60426d4f4a735f9ccf27f3d7f5be65c1a7..c49d92ee281ce439e2cd948ed3df606624f9a525 100644
--- a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php
+++ b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php
@@ -96,4 +96,9 @@ class ConfigOptionsListConstants
      * Key for modules
      */
     const KEY_MODULES = 'modules';
+
+    /**
+     * Size of random string generated for store's encryption key
+     */
+    const STORE_KEY_RANDOM_STRING_SIZE = 32;
 }
diff --git a/lib/internal/Magento/Framework/Math/Random.php b/lib/internal/Magento/Framework/Math/Random.php
index 99a94a39554b45102b69f8d7e049f4db08aa2c5f..ca242b5163a321ab2c4b20d9a1338ff323da0807 100644
--- a/lib/internal/Magento/Framework/Math/Random.php
+++ b/lib/internal/Magento/Framework/Math/Random.php
@@ -53,11 +53,8 @@ class Random
                 $str .= $chars[$rand]; // random character in $chars
             }
             fclose($fp);
-        } else {
-            throw new \Magento\Framework\Exception\LocalizedException(
-                new \Magento\Framework\Phrase("Please make sure you have 'openssl' extension installed")
-            );
         }
+
         return $str;
     }
 
@@ -88,10 +85,6 @@ class Random
             $hex = bin2hex($bytes); // hex() doubles the length of the string
             $offset = abs(hexdec($hex) % $range); // random integer from 0 to $range
             fclose($fp);
-        } else {
-            throw new \Magento\Framework\Exception\LocalizedException(
-                new \Magento\Framework\Phrase("Please make sure you have 'openssl' extension installed")
-            );
         }
 
         return $min + $offset; // random integer from $min to $max
diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json
index 0e4c4462546d2bd603de51e0fde07a46db1922dc..bd731fb3e16dbd7857d0cfe1c1b9da44766c2bba 100644
--- a/lib/internal/Magento/Framework/composer.json
+++ b/lib/internal/Magento/Framework/composer.json
@@ -17,6 +17,7 @@
         "ext-curl": "*",
         "ext-iconv": "*",
         "ext-gd": "*",
+        "ext-openssl": "*",
         "lib-libxml": "*",
         "ext-xsl": "*",
         "magento/magento-composer-installer": "*"
diff --git a/setup/src/Magento/Setup/Model/ConfigGenerator.php b/setup/src/Magento/Setup/Model/ConfigGenerator.php
index 55182db7723f287a1eefc25a3949cdcb636101e8..812cbd1830a38c71f1bcfbebfcd2120915984e1e 100644
--- a/setup/src/Magento/Setup/Model/ConfigGenerator.php
+++ b/setup/src/Magento/Setup/Model/ConfigGenerator.php
@@ -20,11 +20,6 @@ use Magento\Framework\App\ObjectManagerFactory;
  */
 class ConfigGenerator
 {
-    /**
-     * Size of random string generated for store's encryption key
-     */
-    const STORE_KEY_RANDOM_STRING_SIZE = 32;
-
     /**
      * Maps configuration parameters to array keys in deployment config file
      *
@@ -103,7 +98,7 @@ class ConfigGenerator
             if ($currentKey === null) {
                 $configData->set(
                     ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY,
-                    md5($this->random->getRandomString(self::STORE_KEY_RANDOM_STRING_SIZE))
+                    md5($this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE))
                 );
             }
         }