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

2023-11-22 Thread 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 (
https://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.

  


  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=;

 
 -BEGIN RSA PRIVATE KEY-
 ===KEY===
 -END RSA PRIVATE KEY-
  

  


Thanks,


Gil Espinoza


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

2023-11-22 Thread Günter Paul
Hi Gil,
I'm using DKIM without problems. Maybe the blanks in private key are the 
problem? Can you check it?

Your file:
 
 -BEGIN RSA PRIVATE KEY-
 ===KEY===
 -END RSA PRIVATE KEY-
  

My file:
 
-BEGIN RSA PRIVATE KEY-
===KEY===
-END RSA PRIVATE KEY-
  

Best wishes
Günter

> Gilberto Espinoza  hat am 22.11.2023 17:03 CET 
> geschrieben:
> 
>  
> 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 (
> https://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.
> 
>   
> 
> 
>   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=;
> 
>  
>  -BEGIN RSA PRIVATE KEY-
>  ===KEY===
>  -END RSA PRIVATE KEY-
>   
> 
>   
> 
> 
> Thanks,
> 
> 
> Gil Espinoza

-
To unsubscribe, e-mail: server-user-unsubscr...@james.apache.org
For additional commands, e-mail: server-user-h...@james.apache.org



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

2023-11-23 Thread Benoit TELLIER
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: btell...@linagora.com
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.

  


  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=;

 
 -BEGIN RSA PRIVATE KEY-
 ===KEY===
 -END RSA PRIVATE KEY-
  

  


Thanks,


Gil Espinoza


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

2023-11-23 Thread Gilberto Espinoza
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.op

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

2023-11-23 Thread Rene Cordier

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.AbstractState

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

2023-11-24 Thread Gilberto Espinoza
Hi Rene,

Thanks for the suggestions. I tried regenerating the keys with openssl and
I still got the same problem. I switched to ssh-keygen to generate the
keys. It still crashed but with a different error message. I also placed
the private key in the xml file so that there are no spaces between the
beginning of the line and the first character of the line. Below is the
error message.

23:57:54.669 [ERROR] o.a.j.m.l.AbstractStateMailetProcessor - Unable to
init mailet org.apache.james.jdkim.mailets.DKIMSign
java.lang.IllegalArgumentException: failed to construct sequence from
byte[]: unexpected end-of-contents marker
at org.bouncycastle.asn1.ASN1Sequence.getInstance(ASN1Sequence.java:101)
... 43 common frames omitted
Wrapped by: org.bouncycastle.openssl.PEMException: problem creating RSA
private key: java.lang.IllegalArgumentException: failed to construct
sequence from byte[]: unexpected end-of-contents marker
at org.bouncycastle.openssl.PEMParser$RSAKeyPairParser.parse(Unknown Source)
... 42 common frames omitted
Wrapped by: org.bouncycastle.openssl.PEMException: problem creating RSA
private key: java.lang.IllegalArgumentException: failed to construct
sequence from byte[]: unexpected end-of-contents marker
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: problem
creating RSA private key: java.lang.IllegalArgumentException: failed to
construct sequence from byte[]: unexpected end-of-contents marker
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.In

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

2023-11-25 Thread David Matthews
hi Giberto

This is not up to date (James 3.3.0), but maybe nothing has changed in this 
area? i had no problem getting outgoing email DKIM signed (not checking 
incoming mail). How I did it is described at

https://dmatthews.org/email_server/java_email.html

--
David Matthews
m...@dmatthews.org


-
To unsubscribe, e-mail: server-user-unsubscr...@james.apache.org
For additional commands, e-mail: server-user-h...@james.apache.org