Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctrine:encrypt:database fails - trying to decrypt #47

Open
dotZoki opened this issue Jan 13, 2021 · 2 comments
Open

doctrine:encrypt:database fails - trying to decrypt #47

dotZoki opened this issue Jan 13, 2021 · 2 comments

Comments

@dotZoki
Copy link

dotZoki commented Jan 13, 2021

I'm trying to switch from Defuse to Halite. So I first used bin/sf doctrine:decrypt:database it went OK.
Switched config to Halite and run bin/sf doctrine:encrypt:database and it failed with Invalid message authentication code. I figured out it still tries to decrypt fields on postLoad event.

https://github.com/GiveMeAllYourCats/DoctrineEncryptBundle/blob/b24750061f838e7c9caab6d6effa6b301b709028/src/Subscribers/DoctrineEncryptSubscriber.php#L149

I was excepting it will not decrypt nothing when encrypt cli command was called.

@dotZoki
Copy link
Author

dotZoki commented Jan 14, 2021

I also tried encrypting unencrypted DB. It failed on postUpdate() call.

https://github.com/GiveMeAllYourCats/DoctrineEncryptBundle/blob/b24750061f838e7c9caab6d6effa6b301b709028/src/Subscribers/DoctrineEncryptSubscriber.php#L125

Dumping entity before the actual call of processFields in postUpdate() shows a field (countryCode) which is plain string in DB is encrypted during runtime but somehow fails on being decrypted in runtime (DoctrineEncryptSubscriber.php#L125)

@dotZoki
Copy link
Author

dotZoki commented Jan 14, 2021

OK, I found issue on my side. There is setter on a field and that setter does strtoupper on a string. So when using bin/sf doctrine:encrypt:database it encrypts the string and sets it back to entity and when it goes through setter it gets uppercased.

I still need to force uppercase on that string, but want to avoid it when doing encryption. Is this possible, bug or feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant