Re: DKIM -- crashes at James startup with error: malformed sequence in RSA private key

Rene Cordier <[email protected]>
Newsgroups gmane.comp.jakarta.james.user
Message-ID <[email protected]>
Hello,

Maybe something wrong with the way the key has been generated? Did you 
try to generate an other one? Or even use an online tool to generate one 
and see if you still get the same error?

Regards,

Rene.

On 11/23/23 21:13, Gilberto Espinoza wrote:
> Dear Benoit and Günter,
>
> Thank you for your responses.
>
> @Günter: I have tried your suggestions without success. I will give it
> another try.
>
> @Benoit: Here is the full error message. Please let me know if you need
> additional information from the log file
>
> 15:04:21.969 [ERROR] o.a.j.m.l.AbstractStateMailetProcessor - Unable to
> init mailet org.apache.james.jdkim.mailets.DKIMSign
> org.bouncycastle.openssl.PEMException: malformed sequence in RSA private key
> at org.bouncycastle.openssl.PEMParser$RSAKeyPairParser.parse(Unknown Source)
> ... 42 common frames omitted
> Wrapped by: org.bouncycastle.openssl.PEMException: malformed sequence in
> RSA private key
> at org.bouncycastle.openssl.PEMParser$KeyPairParser.parseObject(Unknown
> Source)
> at org.bouncycastle.openssl.PEMParser.readObject(Unknown Source)
> at
> org.apache.james.jdkim.mailets.DKIMSign.extractPrivateKey(DKIMSign.java:197)
> at org.apache.james.jdkim.mailets.DKIMSign.init(DKIMSign.java:135)
> ... 38 common frames omitted
> Wrapped by: javax.mail.MessagingException: Problem during reading:
> malformed sequence in RSA private key
> at org.apache.james.jdkim.mailets.DKIMSign.init(DKIMSign.java:141)
> at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:238)
> at
> org.apache.james.utils.GuiceMailetLoader.getMailet(GuiceMailetLoader.java:57)
> ... 36 common frames omitted
> Wrapped by: javax.mail.MessagingException: Can not load mailet
> org.apache.james.jdkim.mailets.DKIMSign
> at
> org.apache.james.utils.GuiceMailetLoader.getMailet(GuiceMailetLoader.java:60)
> at
> org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.parseConfiguration(AbstractStateMailetProcessor.java:327)
> at
> org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.init(AbstractStateMailetProcessor.java:116)
> at
> org.apache.james.mailetcontainer.impl.MailetProcessorImpl.init(MailetProcessorImpl.java:192)
> at
> org.apache.james.mailetcontainer.impl.CompositeProcessorImpl.createMailProcessor(CompositeProcessorImpl.java:72)
> at
> org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor.init(AbstractStateCompositeProcessor.java:171)
> at
> org.apache.james.mailetcontainer.impl.CompositeProcessorImpl.init(CompositeProcessorImpl.java:60)
> at
> org.apache.james.modules.server.MailetContainerModule$MailetModuleInitializationOperation.configureProcessors(MailetContainerModule.java:187)
> at
> org.apache.james.modules.server.MailetContainerModule$MailetModuleInitializationOperation.initModule(MailetContainerModule.java:181)
> at
> com.github.fge.lambdas.consumers.ConsumerChainer.lambda$sneakyThrow$9(ConsumerChainer.java:73)
> at java.base/java.util.stream.ReferencePipeline$11$1.accept(Unknown Source)
> at java.base/java.util.stream.DistinctOps$1$2.accept(Unknown Source)
> at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown
> Source)
> at
> java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Unknown
> Source)
> at
> java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Unknown
> Source)
> at java.base/java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
> at
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
> at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown
> Source)
> at
> java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown
> Source)
> at
> java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
> at
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
> at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown
> Source)
> at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
> at
> org.apache.james.utils.InitializationOperations.processStartables(InitializationOperations.java:51)
> at
> org.apache.james.utils.InitializationOperations.initModules(InitializationOperations.java:41)
> at org.apache.james.GuiceJamesServer.start(GuiceJamesServer.java:93)
> at org.apache.james.JamesServerMain.main(JamesServerMain.java:30)
> at org.apache.james.JPAJamesServerMain.main(JPAJamesServerMain.java:110)
> 15:04:21.985 [ERROR] o.a.j.m.l.AbstractStateMailetProcessor - Caused by
> nested exception:
> org.bouncycastle.openssl.PEMException: malformed sequence in RSA private key
> at org.bouncycastle.openssl.PEMParser$RSAKeyPairParser.parse(Unknown Source)
> ... 42 common frames omitted
> Wrapped by: org.bouncycastle.openssl.PEMException: malformed sequence in
> RSA private key
> at org.bouncycastle.openssl.PEMParser$KeyPairParser.parseObject(Unknown
> Source)
> at org.bouncycastle.openssl.PEMParser.readObject(Unknown Source)
> at
> org.apache.james.jdkim.mailets.DKIMSign.extractPrivateKey(DKIMSign.java:197)
> at org.apache.james.jdkim.mailets.DKIMSign.init(DKIMSign.java:135)
> ... 38 common frames omitted
> Wrapped by: javax.mail.MessagingException: Problem during reading:
> malformed sequence in RSA private key
> at org.apache.james.jdkim.mailets.DKIMSign.init(DKIMSign.java:141)
> at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:238)
> at
> org.apache.james.utils.GuiceMailetLoader.getMailet(GuiceMailetLoader.java:57)
> at
> org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.parseConfiguration(AbstractStateMailetProcessor.java:327)
> at
> org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor.init(AbstractStateMailetProcessor.java:116)
> at
> org.apache.james.mailetcontainer.impl.MailetProcessorImpl.init(MailetProcessorImpl.java:192)
> at
> org.apache.james.mailetcontainer.impl.CompositeProcessorImpl.createMailProcessor(CompositeProcessorImpl.java:72)
> at
> org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor.init(AbstractStateCompositeProcessor.java:171)
> at
> org.apache.james.mailetcontainer.impl.CompositeProcessorImpl.init(CompositeProcessorImpl.java:60)
> at
> org.apache.james.modules.server.MailetContainerModule$MailetModuleInitializationOperation.configureProcessors(MailetContainerModule.java:187)
> at
> org.apache.james.modules.server.MailetContainerModule$MailetModuleInitializationOperation.initModule(MailetContainerModule.java:181)
> at
> com.github.fge.lambdas.consumers.ConsumerChainer.lambda$sneakyThrow$9(ConsumerChainer.java:73)
> at java.base/java.util.stream.ReferencePipeline$11$1.accept(Unknown Source)
> at java.base/java.util.stream.DistinctOps$1$2.accept(Unknown Source)
> at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown
> Source)
> at
> java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Unknown
> Source)
> at
> java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Unknown
> Source)
> at java.base/java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
> at
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
> at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown
> Source)
> at
> java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown
> Source)
> at
> java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
> at
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
> at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown
> Source)
> at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown
> Source)
> at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
> at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
> at
> org.apache.james.utils.InitializationOperations.processStartables(InitializationOperations.java:51)
> at
> org.apache.james.utils.InitializationOperations.initModules(InitializationOperations.java:41)
> at org.apache.james.GuiceJamesServer.start(GuiceJamesServer.java:93)
> at org.apache.james.JamesServerMain.main(JamesServerMain.java:30)
> at org.apache.james.JPAJamesServerMain.main(JPAJamesServerMain.java:110)
>
> On Thu, Nov 23, 2023 at 3:06 AM Benoit TELLIER <[email protected]>
> wrote:
>
>> Can you share the exact failure log please?
>>
>> --
>>
>> Best regards,
>>
>> Benoit TELLIER
>>
>> General manager of Linagora VIETNAM.
>> Product owner for Team-Mail product.
>> Chairman of the Apache James project.
>>
>> Mail: [email protected]
>> Tel: (0033) 6 77 26 04 58 (WhatsApp, Signal)
>>
>>
>> On Nov 23, 2023 8:19 AM, from Gilberto Espinoza Hello,
>>
>> My instance of James 3.8.0 crashes when I try to add the DKIM configuration
>> in the mailetcontainer.xml. I follow the instructions in the How-To (
>> james.apache.org/howTo/dkim.html). After generating the private and
>> public keys as instructed, I add the following snippet to the
>> mailetcontainer.xml configuration.
>>
>> Upon startup, it crashes with the following error message:
>>
>> 15:19:36.350 [ERROR] o.a.j.m.l.AbstractStateMailetProcessor - Unable to
>> init mailet org.apache.james.jdkim.mailets.DKIMSign
>> org.bouncycastle.openssl.PEMException: malformed sequence in RSA private
>> key
>>
>> The private key is a copy and paste of the contents of the private.pem file
>> that is generated using openssl as instructed in the How-To instructions. I
>> am at a loss on what is causing the malformed sequence. Any suggestions
>> would be appreciated.
>>
>>    <processor state="relay" enableJmx="true">
>>      <mailet match="All" class="org.apache.james.jdkim.mailets.DKIMSign">
>>
>>        <signatureTemplate>v=1; s=james3; d=myrealdomain.net ; h=from :
>> reply-to
>> : subject : date : to : cc : resent-date : resent-from : resent-sender :
>> resent-to : resent-cc : in-reply-to : references : list-id : list-help :
>> list-unsubscribe : list-subscribe : list-post : list-owner : list-archive;
>> a=rsa-sha256; bh=; b=;</signatureTemplate>
>>
>>       <privateKey>
>>       -----BEGIN RSA PRIVATE KEY-----
>>       =======KEY===========
>>       -----END RSA PRIVATE KEY-----
>>        </privateKey>
>>      </mailet>
>>    </processor>
>>
>>
>> Thanks,
>>
>>
>> Gil Espinoza
>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.