# Database error servicing email when decrypting PGP Messages from a specific sender

**URL:** <https://community.ciphermail.com/t/database-error-servicing-email-when-decrypting-pgp-messages-from-a-specific-sender/814>\
**Category:** Gateway\
**Tags:** pgp\
**Created:** [January 6, 2023, 9:02am UTC](https://community.ciphermail.com/t/database-error-servicing-email-when-decrypting-pgp-messages-from-a-specific-sender/814 "2023-01-06T09:02:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpohle](https://dub1.discourse-cdn.com/flex017/user_avatar/community.ciphermail.com/cpohle/32/159_2.png) [@cpohle](https://community.ciphermail.com/u/cpohle)\
**Post date:** [January 6, 2023, 9:02am UTC](https://community.ciphermail.com/t/database-error-servicing-email-when-decrypting-pgp-messages-from-a-specific-sender/814/1 "2023-01-06T09:02:33Z")

</div>

Hello,  
we are using CipherMail Community edition to decrypt PGP Messages in front of our E-Mail Server. That works great but now we got a new communication Partner who sends his invoices via PGP Encryption. When processing these Messages I get an Error “Database error servicing email” and the Mail goes thru unencrypted. The following Lines are in the log:

> 06 Jan 2023 02:41:59 | INFO incoming; MailID: d9a27da3-b160-49f0-a469-2bfc340e4483; Recipients: [recpient(at)domain(dot)de]; Originator: sender(at)domain(dot)de; Sender: sender(at)domain(dot)de; Remote address: x.x.x.x; Subject: Ihre Absender Rechnung Nr.: 6454949049; Message-ID: \<20230106024135.605CC208B8(at)EBIB-PROD.domain(dot)de\>; (mitm.application.djigzo.james.mailets.Log) [Spool Thread #1]  
> 06 Jan 2023 02:41:59 | INFO Filtering subject; MailID: d9a27da3-b160-49f0-a469-2bfc340e4483; Recipients: [recpient(at)domain(dot)de] (mitm.application.djigzo.james.mailets.Default) [Spool Thread #1]  
> 06 Jan 2023 02:41:59 | INFO Subject filtered; MailID: d9a27da3-b160-49f0-a469-2bfc340e4483; Recipients: [recpient(at)domain(dot)de]; Originator: sender(at)domain(dot)de; Sender: sender(at)domain(dot)de; Remote address: x.x.x.x; Subject: Ihre Absender Rechnung Nr.: 6454949049; Message-ID: \<20230106024135.605CC208B8(at)EBIB-PROD.domain(dot)de\>; (mitm.application.djigzo.james.mailets.Log) [Spool Thread #1]  
> 06 Jan 2023 02:41:59 | INFO To internal recipient(s); MailID: d9a27da3-b160-49f0-a469-2bfc340e4483; Recipients: [recpient(at)domain(dot)de] (mitm.application.djigzo.james.mailets.Default) [Spool Thread #1]  
> 06 Jan 2023 02:41:59 | INFO “add security info” is enabled for the recipient(s); MailID: d9a27da3-b160-49f0-a469-2bfc340e4483; Recipients: [recpient(at)domain(dot)de] (mitm.application.djigzo.james.mailets.Default) [Spool Thread #1]  
> 06 Jan 2023 02:41:59 | ERROR Database error servicing email. (mitm.application.djigzo.james.mailets.PGPHandler) [Spool Thread #1]  
> mitm.common.hibernate.DatabaseException: javax.mail.internet.ParseException: Expected MIME type, got ;  
> at mitm.application.djigzo.james.mailets.AbstractTransactedMailet$1.doAction(AbstractTransactedMailet.java:143) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.common.hibernate.DatabaseActionExecutorImpl$1.doAction(DatabaseActionExecutorImpl.java:164) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.common.hibernate.DatabaseActionExecutorImpl.executeTransaction(DatabaseActionExecutorImpl.java:81) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.common.hibernate.DatabaseActionExecutorImpl.executeTransaction(DatabaseActionExecutorImpl.java:158) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.application.djigzo.james.mailets.AbstractTransactedMailet.serviceMail(AbstractTransactedMailet.java:125) [ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.application.djigzo.james.mailets.AbstractDjigzoMailet.service(AbstractDjigzoMailet.java:281) [ciphermail-core.jar:5.4.1.0gd59d06760]  
> at org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:424) [james-2.3.1.jar:?]  
> at org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:405) [james-2.3.1.jar:?]  
> at org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:309) [james-2.3.1.jar:?]  
> at java.lang.Thread.run(Thread.java:829) [?:?]  
> Caused by: javax.mail.internet.ParseException: Expected MIME type, got ;  
> at javax.mail.internet.ContentType.(ContentType.java:95) ~[mail.jar:1.4.5-SNAPSHOT]  
> at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1322) ~[mail.jar:1.4.5-SNAPSHOT]  
> at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1021) ~[mail.jar:1.4.5-SNAPSHOT]  
> at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:419) ~[mail.jar:1.4.5-SNAPSHOT]  
> at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1345) ~[mail.jar:1.4.5-SNAPSHOT]  
> at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2107) ~[mail.jar:1.4.5-SNAPSHOT]  
> at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2075) ~[mail.jar:1.4.5-SNAPSHOT]  
> at mitm.common.security.openpgp.PGPMIMEHandler.createNewMessageFromMIME(PGPMIMEHandler.java:663) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.common.security.openpgp.PGPMIMEHandler.handlePGPMIMEEncrypted(PGPMIMEHandler.java:713) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.common.security.openpgp.PGPMIMEHandler.handleMessage(PGPMIMEHandler.java:270) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.common.security.openpgp.PGPRecursiveValidatingMIMEHandler.handleMessage(PGPRecursiveValidatingMIMEHandler.java:1125) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.common.security.openpgp.PGPRecursiveValidatingMIMEHandler.handleMessage(PGPRecursiveValidatingMIMEHandler.java:1102) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.application.djigzo.james.mailets.PGPHandler.serviceMailTransacted(PGPHandler.java:498) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> at mitm.application.djigzo.james.mailets.AbstractTransactedMailet$1.doAction(AbstractTransactedMailet.java:140) ~[ciphermail-core.jar:5.4.1.0gd59d06760]  
> … 9 more  
> 06 Jan 2023 02:41:59 | INFO Message handling is finished. Sending to final recipient(s); MailID: d9a27da3-b160-49f0-a469-2bfc340e4483; Recipients: [recpient(at)domain(dot)de]; Originator: sender(at)domain(dot)de; Sender: sender(at)domain(dot)de; Remote address: x.x.x.x; Subject: Ihre Absender Rechnung Nr.: 6454949049; Message-ID: \<20230106024135.605CC208B8(at)EBIB-PROD.domain(dot)de\>; (mitm.application.djigzo.james.mailets.Log) [Spool Thread #1]

The Mail arrives in outlook with an Attachment “PGP-MIME version identification” and another Attachment “encrypted.asc”. I can decrypt this attachment with OpenPGP, it decrypts to a file “encrypted”, which I rename to “encrypted.eml”, bring it back to Outlook and I have the decrypted Message. The Beginning of this decrypted Message looks like

> MIME-Version: 1.0  
> To: \<recpient(at)domain(dot)de\>  
> From: \<No-Reply(at)domain(dot)de\>  
> Subject: =?ISO-8859-1?obfuscated  
> Reply-To: \<No-Reply(at)domain(dot)de\>  
> Content-Type: multipart/mixed; boundary=“7HK07gdNP5GA63UuZuxTdpEqyljga1agpxPKMU2p”  
> –7HK07gdNP5GA63UuZuxTdpEqyljga1agpxPKMU2p  
> Content-Type: text/plain; charset=“iso-8859-15”  
> Guten Tag,  
> anbei ¸bermitteln wir Ihre aktuelle Rechnung.  
> Mit freundlichen Gr¸ﬂen  
> Ihre Absender  
> –7HK07gdNP5GA63UuZuxTdpEqyljga1agpxPKMU2p  
> Content-Type: ;name=“B\_5023482686\_25\_01.6454949048.pdf”  
> Content-Transfer-Encoding: base64  
> Content-Disposition: attachment;filename=“B\_5023482686\_25\_01.6454949048.pdf”  
> JVBERi0xLjMNCiXi48/TDQolUlNUWFBERjMgUGFyYW1ldGVyczoNCjIgMCBvYmoNCjw8DQovVHlw  
> ZSAvRm9udERlc2NyaXB0b3INCi9Bc2NlbnQgNzIwDQovQ2FwSGVpZ2h0IDY2MA0KL0Rlc2NlbnQg

I yesterday Upgraded CipherMail to Version: 5.4.1.0gd59d06760 but the error still comes. As other Mails are decrypted/encrypted as they should be, I suspect the problem is caused by how the sender encrypts the mails. “Enable PGP/INLINE to internal” is enabled for this User, but doesn’t change the behaviour.

Any Help much appreciated,  
Christian

---

<div class="post-metadata">

**Author:** ![martijn](https://dub1.discourse-cdn.com/flex017/user_avatar/community.ciphermail.com/martijn/32/127_2.png) [@martijn](https://community.ciphermail.com/u/martijn)\
**Post date:** [January 6, 2023, 9:22am UTC](https://community.ciphermail.com/t/database-error-servicing-email-when-decrypting-pgp-messages-from-a-specific-sender/814/2 "2023-01-06T09:22:35Z")

</div>

> Content-Type: ;name=“B\_5023482686\_25\_01.6454949048.pdf”

This looks like an invalid Content-Type because the actual type is missing.

Is this the Content-Type of the decrypted part? Or is this a typo?

---

<div class="post-metadata">

**Author:** ![cpohle](https://dub1.discourse-cdn.com/flex017/user_avatar/community.ciphermail.com/cpohle/32/159_2.png) [@cpohle](https://community.ciphermail.com/u/cpohle)\
**Post date:** [January 6, 2023, 9:38am UTC](https://community.ciphermail.com/t/database-error-servicing-email-when-decrypting-pgp-messages-from-a-specific-sender/814/3 "2023-01-06T09:38:09Z")

</div>

Hi Martijn,

thank you for your fast reply. This is the actual content type they send, this line was not obfuscated by me. That would match to the error line

> Expected MIME type, got ;

right? Can I do something to solve it?

Christian

---

<div class="post-metadata">

**Author:** ![martijn](https://dub1.discourse-cdn.com/flex017/user_avatar/community.ciphermail.com/martijn/32/127_2.png) [@martijn](https://community.ciphermail.com/u/martijn)\
**Post date:** [January 6, 2023, 10:25am UTC](https://community.ciphermail.com/t/database-error-servicing-email-when-decrypting-pgp-messages-from-a-specific-sender/814/4 "2023-01-06T10:25:49Z")

</div>

I don’t think there is an easy solution. The Content-Type is invalid. I think javamail, which is responsible for MIME handling, supports some cleanup functionality but this requires additional Java code.

---

<div class="post-metadata">

**Author:** ![cpohle](https://dub1.discourse-cdn.com/flex017/user_avatar/community.ciphermail.com/cpohle/32/159_2.png) [@cpohle](https://community.ciphermail.com/u/cpohle)\
**Post date:** [January 6, 2023, 11:26am UTC](https://community.ciphermail.com/t/database-error-servicing-email-when-decrypting-pgp-messages-from-a-specific-sender/814/5 "2023-01-06T11:26:47Z")

</div>

Hi Martijn,  
thank you really for pointing me in the right direction, I haven’t seen this fact in the logs. I’m now able to tell the Partner that the initial E-Mail that is encrypted in the PGP Envelope should have

> Content-type: **application/pdf** ; name=“B\_5023482686\_25\_01.6454949048.pdf”;

Instead of

> Content-Type: ;name=“B\_5023482686\_25\_01.6454949048.pdf”

So I can tell them (and our users), it is their fault and they have to correct it.  
Again, thank you for your help.

Christian
