Asn1DecoderNet5 1.6.0
See the version list below for details.
dotnet add package Asn1DecoderNet5 --version 1.6.0
NuGet\Install-Package Asn1DecoderNet5 -Version 1.6.0
<PackageReference Include="Asn1DecoderNet5" Version="1.6.0" />
paket add Asn1DecoderNet5 --version 1.6.0
#r "nuget: Asn1DecoderNet5, 1.6.0"
// Install Asn1DecoderNet5 as a Cake Addin #addin nuget:?package=Asn1DecoderNet5&version=1.6.0 // Install Asn1DecoderNet5 as a Cake Tool #tool nuget:?package=Asn1DecoderNet5&version=1.6.0
ASN1Decoder
This library aims to facilitate the parsing of ASN.1 data. It provides a data decoder and a set of methods for their parsing.
Decoding
The class Asn1DecoderNet5.Decoder
is used for decoding DER data. Specifically, the static method Decode
returns an Asn1DecoderNet5.Interfaces.ITag
object.
ITag decodedDataStructure = Asn1DecoderNet5.Decoder.Decode(dataByteArray);
Working with the decoded data
Get a string representation
To obtain the string representation of the ASN.1 structure, you can utilize this extension method:
string result = decodedDataStructure.ToPrettyString(" | ", 128);
This method accepts two parameters. The first parameter is a string used to control the indentation of each element. The second parameter is the maximum length of a single line in the resulting string, not including the indentation.
The resulting string will appear as follows:
SEQUENCE
| OBJECT_IDENTIFIER 1.2.840.113549.1.7.2, signedData, PKCS #7
| [0]
| | SEQUENCE
| | | INTEGER 1
| | | SET
...
Check if the data is X.509 v3 certificate
To check if the data is actual X.509 certificate use this extension method:
bool isCert = decodedDataStructure.IsCertificate();
Get items SubjectAlternativeName
To get items from the Subject Alternative Name (SAN), you can refer to the unit tests provided in the source code. The unit tests in the linked file will demonstrate how to use the library to extract and work with items from the SAN in ASN.1 data.
TL;DR:
[Fact]
public void Should_GetSan_GetsSanWithMailFromCert()
{
var tag = Decoder.Decode(Sources.NormalCertificateWithEmailInSan);
var ok = tag.TryGetSubjectAlternativeName(out var san);
Assert.True(ok);
Assert.NotEmpty(san);
Tags.SAN.Rfc822Name email = null;
foreach (var item in san)
{
if (item.ItemKind == Tags.SAN.SanItemKind.Rfc822Name)
{
email = (Tags.SAN.Rfc822Name)item;
break;
}
}
Assert.NotNull(email);
Assert.Equal("kral@ica.cz", email.Content);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.6.1 | 411 | 1/22/2024 | |
1.6.0 | 271 | 11/8/2023 | |
1.5.3 | 434 | 11/28/2022 | |
1.5.2 | 326 | 11/28/2022 | |
1.5.1 | 348 | 11/20/2022 | |
1.5.0 | 540 | 8/21/2022 | |
1.4.0 | 1,006 | 3/7/2022 | |
1.3.0 | 470 | 1/21/2022 | |
1.2.0 | 323 | 12/9/2021 | |
1.1.0 | 406 | 10/28/2021 | |
1.0.8 | 411 | 10/5/2021 | |
1.0.7 | 349 | 10/4/2021 | |
1.0.6 | 337 | 9/20/2021 | |
1.0.5 | 430 | 9/12/2021 | |
1.0.4 | 411 | 9/12/2021 | |
1.0.2 | 391 | 9/11/2021 |
Added extension methods for easier data parsing. Revisited OID class. Decoding (OID parsing) optimizations.