ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Encryption key x smtp email


#1

Hi,

Somebody can help me to figure out where is the error?

I’m trying do fix it… checked all my e-mail accounts.

Got this error:

Title
frappe.email.queue.flush

Error

{‘event’: u’all’, ‘retry’: 0, ‘log’: <function log at 0x7fc2645ea8c0>, ‘site’: u’bench-manager.local’, ‘job_name’: u’frappe.email.queue.flush’, ‘method_name’: u’frappe.email.queue.flush’, ‘method’: <function flush at 0x7fc264588050>, ‘user’: u’Administrator’, ‘kwargs’: {}, ‘is_async’: True}
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 103, in execute_job
method(**kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 341, in flush
check_email_limit([])
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 232, in check_email_limit
smtp_server = SMTPServer()
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/smtp.py”, line 167, in init
self.setup_email_account(append_to)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/smtp.py”, line 170, in setup_email_account
self.email_account = get_outgoing_email_account(raise_exception_not_set=False, append_to=append_to, sender=sender)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/smtp.py”, line 82, in get_outgoing_email_account
email_account = get_default_outgoing_email_account(raise_exception_not_set=raise_exception_not_set)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/smtp.py”, line 117, in get_default_outgoing_email_account
email_account.password = email_account.get_password(raise_exception=False)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 648, in get_password
return get_decrypted_password(self.doctype, self.name, fieldname, raise_exception=raise_exception)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/password.py”, line 47, in get_decrypted_password
return decrypt(auth[0][0])
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/password.py”, line 150, in decrypt
frappe.throw(_(‘Encryption key is invalid, Please check site_config.json’))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 339, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 325, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 298, in _raise_exception
raise raise_exception(msg)
ValidationError: Encryption key is invalid, Please check site_config.json

Somebody can help me to fix it?


#2

Hi, from my experience that error can occurs after database restore.
so did you recently restore database to a new server?
or did you change anything in the file site_config.json?


#3

Yes, I had to restore… Have I mess something?

I had bench.manager with a different encryption key of my site. I don’t know if I change it on my site will make it work. The bench.manager is chmod locked.


#4

Hi @xickomesquita

Did you restore to a different server? If so, you need to copy the encryption key in the site_config.json file on the old server and use that to replace the encryption key on the new server

Cheers


#5

No you have not messed anything. there is a file called site_config.json it is in directory

~frappe-bench/sites/site1.local/site_config.json

That file has it has encryption keys in it. so if you still have access to your previous instance, go to that directory copy the encryption keys and paste them on your new instance in the same file site_config.json


#6

Yes that’s the correct solution.
As I faced the same issue when backing up one of my instance and restoring.

But i would like to know if there is any way to restore if the encryption is lost?


#7

There is no other way. At-least none that I know of.
You will be able to restore but some features (like email) won’t work without original encryption keys


#8

The site_config.json is included on the backup?

Thanks!!


#9

No its not included in backup.
Since it’s not safe to have backup and encryption keys both in one place


#10

So… I don’t know were to get it… I have 2 keys… One in my site, and other in the bench-manager… When I use the bench-manager, it doesn’t work, and I got the alert “Encryption key is invalid…” like. When I use the site_config, everything works fine, but the email doesn’t work anymore…


#11

what you need is the original encryption keys which come from the server instance where you took that backup from.
so if you still have access to that previous instance, go to this file and copy the encryption keys

frappe-bench/sites/site1.local/site_config.json

paste them in the same file of your new server instance


#12

One last question: What if I delete the encrypt key from config.json? I did it, and the system is still working…


#13

from personal experience I noticed that some features won’t work without encryption keys. So you might have to try testing out all the modules you use to be sure if everything works.


#14

You are right. It doesn’t work. Still trying!!


#15

I believe I did the trick!

  1. delete encrypt key from config.json
  2. delete all the e-mail setup
  3. input the e-mail server
  4. input the e-mail account
    4.1) input the original password from smtp server (i’m using SES from AWS) (it will insert a new encrypt key on your config.json file)
  5. change the password to a new psswd from SES service

voilá!

Now, I get the e-mails… the error is still there… Next try…


#16

The solution is here. I had just reset the password for the Email accounts and it worked as I only had 1 email account configured.


#17

In my case, it is the partial solution!!

Now, i’ve got 554 error from SES…

Thanks!


#18

That seems like email address verification issue based on this aws support url.

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-response-codes.html


#19

Done. I had to input all the e-mails, and then, delete all the unsent e-mail queue. Now, all the e-mails are ok!