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

Error On Xamarin Forms Platform #153

Open
NiladriPadhy opened this issue Mar 15, 2021 · 9 comments
Open

Error On Xamarin Forms Platform #153

NiladriPadhy opened this issue Mar 15, 2021 · 9 comments

Comments

@NiladriPadhy
Copy link

NiladriPadhy commented Mar 15, 2021

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(5,5): Error XALNK7000: Mono.Linker.MarkException: Error processing method: 'System.Byte[] Jose.ConcatKDF::DeriveKey(System.Security.Cryptography.CngKey,System.Security.Cryptography.CngKey,System.Int32,System.Byte[],System.Byte[],System.Byte[],System.Byte[])' in assembly: 'jose-jwt.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Security.Cryptography.ECDiffieHellmanCng
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType (Mono.Cecil.TypeReference reference) [0x00013] in :0
at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x0002c] in :0
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00047] in :0
at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x001b1] in :0
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x0001b] in :0
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00047] in :0
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue () [0x0000a] in :0
at Mono.Linker.Steps.MarkStep.Process () [0x000f6] in :0
at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x0000d] in :0
at MonoDroid.Tuner.MonoDroidMarkStep.Process (Mono.Linker.LinkContext context) [0x0000b] in :0
at Mono.Linker.Pipeline.ProcessStep (Mono.Linker.LinkContext context, Mono.Linker.Steps.IStep step) [0x0000d] in :0
at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x0000f] in :0
at MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in :0
at MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options, Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context) [0x00071] in :0
at Xamarin.Android.Tasks.LinkAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x001dd] in :0
at Xamarin.Android.Tasks.LinkAssemblies.RunTask () [0x0001b] in :0
at Xamarin.Android.Tasks.AndroidTask.Execute () [0x00000] in :0 (XALNK7000) (XFPaypointQR.Android)
/Users/niladripadhy/Projects/Xamarin/paypointqr-xf/XFPaypointQR/XFPaypointQR.iOS/MTOUCH: Error MT2101: Can't resolve the reference 'System.Security.Cryptography.ECDiffieHellmanCng', referenced from the method 'System.Byte[] Jose.ConcatKDF::DeriveKey(System.Security.Cryptography.CngKey,System.Security.Cryptography.CngKey,System.Int32,System.Byte[],System.Byte[],System.Byte[],System.Byte[])' in 'System.Security.Cryptography.Cng, Version=4.3.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. (MT2101) (XFPaypointQR.iOS)

Workaround solution: Set Linker Option on platform Specific Project(iOS and Android): Don't link.

@NiladriPadhy NiladriPadhy changed the title Error On Xamarin Platform Error On Xamarin Forms Platform Mar 15, 2021
@dvsekhvalnov
Copy link
Owner

Hi @NiladriPadhy ,
not sure what the issue is about?

Library is not claiming Xamarin support, so unlikely i can be very helpful in troubleshooting it.

@NiladriPadhy
Copy link
Author

NiladriPadhy commented Mar 19, 2021

Hi @dvsekhvalnov,
Thank you for your response.
Found the issue in ConcatKDF.cs, DeriveKey () method. Can you please provide support/compatible code for NETSTANDARD2_0?

As a temporary workaround solution downloaded the source and refer to my Xamarin Solution Project and modified code with at end of DeriveKey() method.
#else
throw new NotImplementedException("not yet");
Now I am able to compile the code and run the code without any issues. Might be DeriveKey() method is not being called in my JWT integration.

It would be great, if you provide the permanent solution and provide Xamarin Forms support.

@dvsekhvalnov
Copy link
Owner

@NiladriPadhy, yeah i can take a look if it is possible.

Or if you already have fixes that are compatible with netstandard 2.0 - feel free to submit PR, or simply drop them in comment, will be helpful.

@NiladriPadhy
Copy link
Author

@dvsekhvalnov In my jwt integration ConcatKDF.DeriveKey () is not being used, so as a temporary work around Just I have added to ignore the error.
#else
throw new NotImplementedException("not yet");
I am a Xamarin.Forms mobile App developer. I am not sure about it.

@dvsekhvalnov
Copy link
Owner

@NiladriPadhy , i have v3.1.1 published on nuget: https://www.nuget.org/packages/jose-jwt/3.1.1
(or https://github.com/dvsekhvalnov/jose-jwt/releases/tag/v3.1.1)

Have updated ConcatKDF.cs according to our conversation, would you mind to try it and let me know if it works as expected now? I don't have any Xamarin setup to try it myself unfortunately.

@ekjuanrejon
Copy link

I upgrade my xamarin project to 3.1.1 and I still have the issue. I have to downgrade to 2.6.1

@dvsekhvalnov
Copy link
Owner

Hi @ekjuanrejon , thanks for sharing feedback.

I probably need more information to make any meaningful fix, as i don't have any Xamarin setup myself.

@enricopay
Copy link

Same issue here, let me know if you need additional information

@dvsekhvalnov
Copy link
Owner

Well, @enricopay if you have an idea how conditional compilation should be set here: https://github.com/dvsekhvalnov/jose-jwt/blob/7793e4280ee923489233538cabe19e427005a1bf/jose-jwt/crypto/ConcatKDF.cs

to make it work with Xamarin. I'd happy to make custom build for you to try.

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

No branches or pull requests

4 participants