none
Question regarding the class CspParameters RRS feed

  • Question

  • Hello,

    I have a question regarding the class CspParameters.

    it says on the MSDN page that it's supported in the Net Core and Net Standard, but unfortunately, it's not the case in all the operating systems, it only works in Windows. On Linux, i have an exception saying that it's not supported on the current system, and on Windows, it works correctly without exception.

    Why it's not specified on the msdn page ? i thought that the Net Standard library offers a full compatibility in all the systems.

    Does this means that there is some classes that are included on the Net standard library and they don't work on all the operating systems ? If so, there is a need to specify it on the class MSDN's page.

    For your information, i have done the test in Ubuntu and Windows 10, with net core 2.0 and the last version 3.1

    Thanks by advance for your answers.


    Tuesday, March 3, 2020 10:10 PM

All replies

  • On .NET Core you may need to install additional packages to function properly on non-Windows platform.

    Say, System.Security.Cryptography.Csp .

    Wednesday, March 4, 2020 1:16 AM
    Answerer
  • Hi Bader MESSAOUDI,

    Thank you for posting here.

    You may need to use RSA.Create() instead of CryptoServiceProvider to get an implementation compatible with your environment.

    Here are two references you can refer to:

    1. Using Asymmetric Key on .Net Core
    2. implement RSA in .NET core

    Hope them could be helpful.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 4, 2020 7:27 AM
    Moderator
  • FYI, the package I suggested is published by Microsoft dotnet team themselves to address the platform difference.
    Wednesday, March 4, 2020 9:25 AM
    Answerer
  • hi cheong00,

    Thanks for your answer, by the package itself doesn't work, i have the same bug. It's obvious that it works only on windows but the problem, it's not specified on the class page or the nuget page that you have sent me.

    Wednesday, March 4, 2020 7:07 PM
  • Hi Xingyu Zhao,

    Thanks for your answer, just as i expected, the CspParameters is not compatible with all the operating systems.

    Can you tell me if it's possible to add this precision on the MSDN class page ? If not, it will be very confusing for anyone who haven't faced the problem...

    Wednesday, March 4, 2020 7:12 PM
  • That would be strange because it supports MonoAndroid and Xamarin.iOS. I don't expect it to work on these targets if it has "Windows system only" dependency.

    On ".NET Standard 1.3" target it fetches System.Security.Cryptography.Algorithms/Encoding/Primitives as well so I think it should have all the dependency for it to work.

    Have you also copied the DLLs in your "publish" folder to target machine? (Pay special attention on the "Native Dependencies" section)



    Thursday, March 5, 2020 1:37 AM
    Answerer
  • Yes, i have copied them as well, still have the same exception :

    Unhandled exception. System.PlatformNotSupportedException: 'CspParameters' requires Windows Cryptographic API (CAPI), which is not available on this platform.
       at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters)

    Your link about the native dependencies seems interesting, but unfortunately, we don't have clear indications on MSDN about the classes that are impacted by the details exposed on your link.

    Thursday, March 5, 2020 9:31 PM
  • Hi Bader MESSAOUDI,

    You can give your feedback in following reference:

    MicrosoftDocs/feedback

    Besides, you can also report an issue in Developer Community for more help.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 9, 2020 6:54 AM
    Moderator