You can use CryptoSys PKI Pro with .NET Core (dotnetcore) on an x64 Linux system. To use on Windows see Using CryptoSys PKI with .NET Core on Windows.
Using CryptoSys PKI with .NET Core on Linux is different from using on Windows in two ways.
diCrPKI.dll
CryptoSysPKI.cs
in your project instead of making a reference to the .NET DLL diCrSysPKINet.dll
setuppkiso.sh
after setting the "+x" mode to executabledotnet --info dotnet --list-sdks
If this simple test project works, then everything else will work...
dotnet new console -n pki_simple -o pki_simple2. Copy the file
CryptoSysPKI.cs
into this directory.
Expected directory structure
\---pki_simple | CryptoSysPKI.cs | pki_simple.csproj | Program.cs | \---obj project.assets.json ... etc.3. Change directory into project
cd pki_simple4. If you are using dotnet9.0 or later, edit the file
pki_simple.csproj
and change the line
<Nullable>enable</Nullable>
to
<Nullable>disable</Nullable>
This prevents messages of the form warning CS8625: Cannot convert null literal to non-nullable reference type
.
This annoying warning is not relevant for our code.
Program.cs
with the following:
using System.Runtime.InteropServices; using System.Text; using CryptoSysPKI; public class CryptoSysPKIWrapper { [STAThread] static void Main(string[] args) { Console.WriteLine("CryptoSysPKI core Version is " + General.Version()); Console.WriteLine("CompileTime= " + General.CompileTime()); } }6. Compile and run
dotnet build dotnet runThe output should be similar to
CryptoSysPKI core Version is 230001 CompileTime= Dec 15 2024 20:25:50
dotnet new console -n TestPKIcsharp -o TestPKIcsharpCopy
CryptoSysPKI.cs
and TestPKIcsharp.cs
into the test folder and unzip the test files into a sub-directory pkiDotNetTestFiles
.
(All these files are in Downloads below.)
\---TestPKIcsharp | CryptoSysPKI.cs | TestPKIcsharp.cs | TestPKIcsharp.csproj | +---pkiDotNetTestFiles | alice-lamps.crt | alice-lamps.p12 | AlicePrivRSASign.p8e | AlicePubRSA.pub | AliceRSAPSS.p8 | AliceRSAPSS.p8e | ... etc. \---obj project.assets.json project.nuget.cache ... etc.Edit the project file
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net9.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>disable</Nullable> </PropertyGroup> <PropertyGroup> <StartWorkingDirectory>./pkiDotNetTestFiles/</StartWorkingDirectory> </PropertyGroup> </Project>Build and run.
dotnet build dotnet run
The tests show that all the features of CryptoSys PKI will work on a Linux system using dotnetcore. If these work, then any of the examples provided should work. Furthermore, you should be able to pick out the code you need to do whatever task you require.
/usr/lib
directory. You should see the following links
/usr/lib/diCrPKI.dll.so -> /usr/lib/libcryptosyspki.so.23 /usr/lib/libcryptosyspki.so.23 -> /usr/lib/libcryptosyspki.so.23.0.1The "dll" means nothing in Linux but making that link from
diCrPKI.dll.so
means we don't have to change the [DllImport] statements in the source code.
Download the test files used above: pki-dotnetcore-tests.zip.
CryptoSysPKI.cs pkiDotNetTestFiles.zip Program.cs TestPKIcsharp.csThe file
TestPKIcsharp.cs
has been edited since its last release v23.0.0 in September 2024 to fix up a few Windows-centric issues
(hard-coded backslash file separator, Windows 1252 encoding not supported in dotnet).
To contact us or comment on this page, please send us a message.
This page first published 18 December 2024. Last updated 19 December 2024