Yubico / Yubico.NET.SDK

A YubiKey SDK for .NET developers
Apache License 2.0
96 stars 48 forks source link

SDK Support For Mac Catalyst #40

Open igalfsg opened 1 year ago

igalfsg commented 1 year ago

Hi,

Is there a compatibility reason that Mac Catalyst is not supported? or is this something that could be enabled on my side? https://github.com/dotnet/maui/issues/13855

Thanks, Igal

GregDomzalski commented 1 year ago

Hey @igalfsg . That's strange... So based on the exception you listed in the other thread, it looks like RuntimeInformation.IsOSPlatform(OSPlatform.OSX) returns false on Mac Catalyst systems.

I don't see any other options on that particular API to discover the system.

There is the System.OperatingSystem class... but that is only available in .NET 5+. Unfortunately we have to target .NET Standard 2.0 since many of our customers still use .NET Framework 4.x

I'll have to investigate this further to see what our options are.

Can you please confirm that RuntimeInformation.IsOSPlatform(OSPlatform.OSX) returns false?

Can you also please list what RuntimeInformation.OSDescription returns? Perhaps we can utilize that.

Hopefully it's a matter of adding an extra if branch here. But if PCSC is not accessible on Catalyst, then I'm afraid this will be a more substantial feature request.

igalfsg commented 1 year ago

Hi Greg,

Thanks for looking into it, as you predicted, the RuntimeInformation.IsOSPlatform(OSPlatform.OSX) returns false, running it on my intel laptop I got the following for RuntimeInformation.OSDescription Darwin 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64

Also for completeness of the test (even if this is not possible in earlier versions) I ran

var test = System.OperatingSystem.IsMacOS(); //returned false
var test1 = System.OperatingSystem.IsMacCatalyst();//returned true
Kormyr commented 9 months ago

Hello @GregDomzalski ,

Any update on this? Is there another issue preventing to do something like this?

public static SdkPlatform OperatingSystem
    {
      get
      {
        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
          return SdkPlatform.Windows;
        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACCATALYST")))
          return SdkPlatform.MacOS;
        return RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? SdkPlatform.Linux : SdkPlatform.Unknown;
      }
    }
GregDomzalski commented 9 months ago

My understanding was that MacCatalyst was also a new API set (i.e. not IOKit).

Is that not the case? If this is as simple as updating the OS check as you've described, I'm happy to make this change.

Are Catalyst apps allowed to access things like IOKit and pcsc-lite?

Kormyr commented 9 months ago

Thank you for the fast answer. The OS check is the first roadblock, and I was just wondering if some testing was done in the meantime on this topic.

DennisDyallo commented 2 weeks ago

Hi @Kormyr !

I have been assigned to maintain this repo. Although we're currently strapped for time and focusing on other areas, it would be interesting to see how your suggested fixes would impact the SDK.

Are you able to try this out and report your findings?

Kormyr commented 2 weeks ago

Hello @DennisDyallo I am glad to see that this SDK has some activity again. I put this issue aside and don't have a Mac to test it anymore. If you have one, it can be really easy to test this change and see if it fails somewhere else.

DennisDyallo commented 2 weeks ago

As I'm not that familiar with the Mac ecosystem. Can you share some of the added value we'd gain from supporting Mac Catalyst as well?

Also note that Yubico has SDK's in Objective-c and Swift as well

@Kormyr @igalfsg

igalfsg commented 2 weeks ago

Hi Dennis,

This task was created so we could support MacCatalyst which would allow onboarding from Mac's and iPads in EZCMS our application for YubiKey onboarding. Since then we have moved on to creating native applications for each.

Kormyr commented 2 weeks ago

As I'm not that familiar with the Mac ecosystem. Can you share some of the added value we'd gain from supporting Mac Catalyst as well?

Also note that Yubico has SDK's in Objective-c and Swift as well

@Kormyr @igalfsg

We created an app using .NET MAUI and expected it to be compatible with Windows and Mac. Because of this Yubikey SDK issue, we don't support Mac right now.

The added value of supporting MacCatalyst would be to prevent other enterprise customers like us losing time.

The very first sentence of this project is:

This is a cross-platform, all encompassing SDK for the YubiKey aimed at large to mid-sized enterprise customers.

GregDomzalski commented 2 weeks ago

(Disclaimer: I am no longer the maintainer of this repo nor am employed by Yubico. Don't worry - all on good terms 😄)

@DennisDyallo just as FYI - It looks like most of the macOS IOKit APIs that the SDK uses are available in the Catalyst environment. Of course, figuring out the correct entitlements and then documenting things is a bit of a to-do. The bigger question mark in my mind is whether PC/SC-lite (i.e. smart card) can work as-is or if there's something bigger that needs to be done. There's always CryptoTokenKit... but that's adding an entirely new back-end for smart card.

Once I get a Mac environment set up again, I'd be happy to take a look at this. I just don't know when exactly that might be.