File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 1717
1818use CustomerManagementFrameworkBundle \Traits \LoggerAware ;
1919use Defuse \Crypto \Crypto ;
20+ use Defuse \Crypto \Encoding ;
21+ use Defuse \Crypto \Exception \BadFormatException ;
2022use Defuse \Crypto \Key ;
2123
2224class DefaultEncryptionService implements EncryptionServiceInterface
@@ -51,7 +53,17 @@ public function getDefaultKey()
5153 throw new \RuntimeException ('Need an encryption secret ' );
5254 }
5355
54- $ this ->defaultKey = Key::loadFromAsciiSafeString ($ secret );
56+ try {
57+ $ this ->defaultKey = Key::loadFromAsciiSafeString ($ secret );
58+ } catch (BadFormatException $ e ) {
59+
60+ //fallback if secret is generated by Pimcore composer plugin and is actually a byte sequence
61+ $ secret = Encoding::saveBytesToChecksummedAsciiSafeString (
62+ \Defuse \Crypto \Key::KEY_CURRENT_VERSION ,
63+ base64_decode ($ secret )
64+ );
65+ $ this ->defaultKey = Key::loadFromAsciiSafeString ($ secret );
66+ }
5567 }
5668
5769 return $ this ->defaultKey ;
You can’t perform that action at this time.
0 commit comments