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

Method 'BlockUpdate' in type 'MimeKit.Cryptography.Ed25519DigestSigner'does not have an implementation. #1121

Closed
jvorwerk opened this issue Dec 20, 2024 · 9 comments

Comments

@jvorwerk
Copy link

Describe the bug

When trying to sign a message with DKIM Signer, I got the following error:

Method 'BlockUpdate' in type 'MimeKit.Cryptography.Ed25519DigestSigner' from assembly 'MimeKit, Version=4.9.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814' does not have an implementation.

Platform (please complete the following information):

  • OS: [Linux, MacOS]
  • .NET Runtime: [e.g. CoreC]
  • .NET Framework: [e.g. .Net 6]
  • MimeKit Version: 4.9.0

To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect that the message will be signed

Code Snippets
If applicable, add code snippets to help explain your problem.

DkimSigner lSigner = new DkimSigner(MTA_Helper.Settings.DKim_PathToPrivateKey, MTA_Helper.Settings.DKim_Domain, MTA_Helper.Settings.DKim_Selector)
  {
      HeaderCanonicalizationAlgorithm = DkimCanonicalizationAlgorithm.Simple,
      BodyCanonicalizationAlgorithm = DkimCanonicalizationAlgorithm.Simple,
      AgentOrUserIdentifier = "@" + MTA_Helper.Settings.DKim_Domain,
      QueryMethod = "dns/txt",
  };
 
  //Sign the message
  List<string> lHeaderList =
      ["From", "Subject", "To", "List-Unsubscribe", "List-Unsubscribe-Post", "X-CSA-Complaints"];
  lSigner.Sign(aMimeMessage, lHeaderList);

Additional context
It used to work in older versions

@jstedfast
Copy link
Owner

Can you paste the full stack trace?

@jvorwerk
Copy link
Author

Here it is:

at MimeKit.Cryptography.DkimSignerBase.CreateSigningContext()
at MimeKit.Cryptography.DkimSigner.DkimSign(FormatOptions options, MimeMessage message, IList1 headers) at MimeKit.Cryptography.DkimSigner.Sign(FormatOptions options, MimeMessage message, IList1 headers)
at MimeKit.Cryptography.DkimSigner.Sign(MimeMessage message, IList`1 headers)
at MNR_Worker_MTA.Classes.MTA_SendMail.SignMessage_Provider(MimeMessage& aMimeMessage)

@jstedfast
Copy link
Owner

Okay, so the problem is that you are actually using the netstandard2.1 version of MimeKit starting with MimeKit 4.9.0 because I dropped net6.0 support (following Microsoft's lead).

BouncyCastle, which provides the ISigner and Idigest interfaces, exposes BlockUpdate(ReadOnlySpan<byte>) for NetCoreApp >= 2.1 and NetStandard >= 2.1, but MimeKit only provides those implementations for NetCore >= 6.0

I tried using the same #if-def's as BouncyCastle, but it won't compile because VS/Roslyn/Compiler insists that that API is only available for net6.0 and net8.0 (I still build for net6.0 locally due to CI build bots lagging behind).

@jstedfast
Copy link
Owner

And it looks like BouncyCastle only builds for the following frameworks:

<TargetFrameworks>net6.0;netstandard2.0;net461</TargetFrameworks>

Which explains why I can't seem to expose that API for netstandard2.1 (because there is no netstandard2.1 assembly of BouncyCastle).

@jstedfast
Copy link
Owner

What is happening is that you are essentially hitting this bug: bcgit/bc-csharp#447

@jstedfast
Copy link
Owner

I think there are 2 possible solutions. Either I bring back net6.0 (which I'd hate to do because then I'm forced to support a framework that Microsoft no longer supports) or we can try to get BouncyCastle to add the netstandard2.1 target (and maybe the net8.0 target while we're at it).

@jstedfast
Copy link
Owner

Or a third option is you update your app to target net8.0 😄

@jvorwerk
Copy link
Author

Thank you very much for your quick response. We have updated our app to target net8.0 and this has solved the problem :-)

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

No branches or pull requests

2 participants