Skip to content

Commit 4e5fa9e

Browse files
committed
Add support linux support for ICertificate.Rfc platform
1 parent d7ada21 commit 4e5fa9e

13 files changed

+26
-73
lines changed

Core/Certificate.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,34 @@ public byte[] CertificatePlainBytes
3838

3939

4040
/// <summary>
41-
/// RFC as parsed from subject/x500UniqueIdentifier
42-
/// see https://oidref.com/2.5.4.45
41+
/// RFC as parsed from subject/x500UniqueIdentifier or OID.2.5.4.45
42+
/// This ensures cross-platform compatibility (Windows/Linux).
4343
/// </summary>
4444
public string Rfc
4545
{
46-
get => SubjectKeyValuePairs.FirstOrDefault(x => x.Key.Equals("OID.2.5.4.45")).Value[..13].Trim();
46+
get
47+
{
48+
// Windows "OID.2.5.4.45"
49+
var rfcPair = SubjectKeyValuePairs.FirstOrDefault(x =>
50+
x.Key.Equals("OID.2.5.4.45", StringComparison.OrdinalIgnoreCase));
51+
52+
// Linux "x500UniqueIdentifier"
53+
if (string.IsNullOrEmpty(rfcPair.Value))
54+
{
55+
rfcPair = SubjectKeyValuePairs.FirstOrDefault(x =>
56+
x.Key.Equals("x500UniqueIdentifier", StringComparison.OrdinalIgnoreCase));
57+
}
58+
59+
// First 13 chars
60+
var value = rfcPair.Value;
61+
62+
if (!string.IsNullOrEmpty(value) && value.Length >= 12)
63+
{
64+
return value[..Math.Min(value.Length, 13)].Trim();
65+
}
66+
67+
throw new Exception("Fiscalapi.Credentials wasn't able to resolve ICertificate.Rfc ");
68+
}
4769
}
4870

4971

bin/Debug/Credentials.4.0.95.nupkg

-41 KB
Binary file not shown.
-41.5 KB
Binary file not shown.

bin/Debug/net6.0/Fiscalapi.Credentials.deps.json

Lines changed: 0 additions & 23 deletions
This file was deleted.
-20.5 KB
Binary file not shown.
-14.4 KB
Binary file not shown.

bin/Debug/net8.0/Fiscalapi.Credentials.deps.json

Lines changed: 0 additions & 23 deletions
This file was deleted.
-20 KB
Binary file not shown.
-14.6 KB
Binary file not shown.

bin/Debug/net9.0/Fiscalapi.Credentials.deps.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)