Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
/ NCALayer.Client Public archive

Client for working with NCALayer via websockets

License

Notifications You must be signed in to change notification settings

Shatilova/NCALayer.Client

Repository files navigation

NCALayer.Client


Remarks of 2024

It’s better to use NCANode for digital signatures instead of NCALayer and this package

The remainder of this document is left as is.


Client for working with NCALayer via websockets

Features

  • installation via NuGet (NCALayer.Client)
  • targeting .NET Standard 2.0 and any newer specification

Usage example

using NCALayer.Client;
using NCALayer.Client.CommonUtils;

var client = new NCACommonUtilsClient();

var exitEvent = new ManualResetEvent(false);
client.Ping(PingCallback);
exitEvent.WaitOne();

exitEvent = new ManualResetEvent(false);
client.RawRequest("kz.gov.pki.knca.commonUtils", "getActiveTokens", null, GetActiveTokensCallback);
exitEvent.WaitOne();

Console.WriteLine("Press any key to terminate the program");
Console.ReadKey();

Task PingCallback(NCAPingResponse response)
{
    Console.WriteLine($"NCA Layer {(response.Success ? string.Empty : "not")} launched");
    exitEvent.Set();
    return Task.CompletedTask;
}

Task GetActiveTokensCallback(NCARawResponse response)
{
    if (response.Success)
        Console.WriteLine($"Raw response: {response.RawResponse}");
    else
        Console.WriteLine($"GetActiveTokensCallback error: {response.ResponseState}");

    exitEvent.Set();
    return Task.CompletedTask;
}

More examples can be found in samples/ folder

TODO

  • improve Distinguished Names parsing in getKeyInfo
  • implement createCAdESFromFile, showFileChooser, createCMSSignatureFromFile from kz.gov.pki.knca.commonUtils
  • implement out-of-box kz.gov.pki.knca.basics module support (NCALayer.Client.NCABasicsClient in future)