I have a specific network environment. Its a DTN(Delay Tolerant Network) network without continous connectivity, situated on the sea, where nodes are ships. There is also a server that is a part of land infrastructure, for clarity lets name it server B. On each ship there is a computer that has custom routing software installed and also acts like a www server. On the www server there is a web email service, where users register and login with their email accounts. They should be able to read their mails and send new emails. Because the network connectivity isn't continous we can't use directly IMAP, POP, SMTP protocols to communicate with mail servers. The idea is that server B on land infrastructure will make the communication on behalf of the user. So web server on the ship will send a message containing mail information encrypted with server B certificate to some transit nodes in the network when they meet and server B decrypt that message and make the IMAP communication. The user can also register at server B and tell it, that it should check inbox messages for every 5min and if there are new mails send them addressed to the ship.
The problem is that passwords stored in the database can't be hashes, because server B wouldn't be able to make the SMTP, IMAP dialog were hashes are unacceptable. My soution is to store in the DB at servers encrypted passwords with server B certificate. When server B wan't to make SMTP it decrypt passwords with it's private key. The drawbacks of this solution is that it is slow and when private key of server B is disclosed then all user passwords can by decrypt.
Is there any better solution for this problem?