Skip to content

Commit f24dea1

Browse files
committed
Add GetDevicePublicKey
1 parent 7169bd2 commit f24dea1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

nanoFramework.System.Net/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
////////////////////////////////////////////////////////////////
1313
// update this whenever the native assembly signature changes //
14-
[assembly: AssemblyNativeVersion("100.1.5.0")]
14+
[assembly: AssemblyNativeVersion("100.1.5.1")]
1515
////////////////////////////////////////////////////////////////
1616

1717
// Setting ComVisible to false makes the types in this assembly not visible

nanoFramework.System.Net/Security/CertificateManager.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,27 @@ public static bool AddCaCertificateBundle(string ca)
7474
/// </remarks>
7575
[MethodImpl(MethodImplOptions.InternalCall)]
7676
public static extern bool AddCaCertificateBundle(byte[] ca);
77+
78+
/// <summary>
79+
/// Loads the device public key from the device certificate store.
80+
/// If public key was found, initializes a new instance of the <see cref="X509Certificate"/>.
81+
/// </summary>
82+
/// <returns>The certificate that was loaded from the certificate store.</returns>
83+
/// <remarks>
84+
/// This method is exclusive of nanoFramework. There is no equivalent in .NET framework.
85+
/// </remarks>
86+
public static X509Certificate GetDevicePublicKey()
87+
{
88+
byte[] certificate = GetDevicePublicKeyRaw();
89+
if (certificate is not null)
90+
{
91+
return new X509Certificate(certificate);
92+
}
93+
94+
return null;
95+
}
96+
97+
[MethodImpl(MethodImplOptions.InternalCall)]
98+
private static extern byte[] GetDevicePublicKeyRaw();
7799
}
78100
}

0 commit comments

Comments
 (0)