Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exception #2

Open
saranyaelumalai-okta opened this issue Jul 26, 2022 · 0 comments
Open

Null pointer exception #2

saranyaelumalai-okta opened this issue Jul 26, 2022 · 0 comments

Comments

@saranyaelumalai-okta
Copy link

Hi,
My public private key pair was created using openssl command. When tried to sign the message using java-utils-mail-dkim library, it throws Null Pointer exception at DkimMessage.getBytes . Please guide on whats causing this issue.

Here is the complete stack trace.

java.lang.NullPointerException: null
	at com.saasure.core.services.mail.eemsg.util.DkimMessage.getBytes(DkimMessage.java:150)
	at com.saasure.core.services.mail.eemsg.util.DkimMessage.writeln(DkimMessage.java:144)
	at com.saasure.core.services.mail.eemsg.util.DkimMessage.writeTo(DkimMessage.java:109)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1315)
	at com.saasure.core.services.mail.impl.EmailSenderImpl.send(EmailSenderImpl.java:345)

Here is how, I used it

....
MimeMessage dkimSignedMessage = dkimSignMessage (mimeMessage, domain, selector, privateKey);
t.sendMessage(dkimSignedMessage, uniqueRecipients);
.....
.....

    private MimeMessage dkimSignMessage(MimeMessage message,  String signingDomain, String selector,  String privateKey)  throws Exception {
        DkimSigner dkimSigner = new DkimSigner(signingDomain, selector, privateKey );
        dkimSigner.setHeaderCanonicalization(Canonicalization.SIMPLE);
        dkimSigner.setBodyCanonicalization(Canonicalization.RELAXED);
        dkimSigner.setSigningAlgorithm(SigningAlgorithm.SHA256_WITH_RSA);
        dkimSigner.setLengthParam(true);
        dkimSigner.setCopyHeaderFields(false);
        return new DkimMessage(message, dkimSigner);
    }


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant