Skip to content

Commit 589f130

Browse files
committed
[unitytls] Native interface is retrieved via static property now instead of function call
1 parent b1a8eca commit 589f130

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

mcs/class/System/Mono.UnityTls/CertHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati
1616
{
1717
byte[] certDer = certificate.GetRawCertData ();
1818
fixed(byte* certDerPtr = certDer) {
19-
UnityTls.GetInterface().unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState);
19+
UnityTls.NativeInterface.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState);
2020
}
2121

2222
var certificateImpl2 = certificate.Impl as X509Certificate2Impl;
@@ -33,7 +33,7 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati
3333
public static X509CertificateCollection NativeChainToManagedCollection (UnityTls.unitytls_x509list_ref nativeCertificateChain, UnityTls.unitytls_errorstate* errorState)
3434
{
3535
X509CertificateCollection certificates = new X509CertificateCollection ();
36-
var unityTls = UnityTls.GetInterface ();
36+
var unityTls = UnityTls.NativeInterface;
3737

3838
var cert = unityTls.unitytls_x509list_get_x509 (nativeCertificateChain, 0, errorState);
3939
for (int i = 0; cert.handle != unityTls.UNITYTLS_INVALID_HANDLE; ++i) {

mcs/class/System/Mono.UnityTls/UnityTls.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,20 @@ public class mono_unity_unitytls_interface
227227
public static bool IsSupported()
228228
{
229229
try {
230-
return GetInterface() != null;
230+
return NativeInterface != null;
231231
} catch (System.Exception) {
232232
return false;
233233
}
234234
}
235235

236-
public static mono_unity_unitytls_interface GetInterface()
236+
public static mono_unity_unitytls_interface NativeInterface
237237
{
238-
if (marshalledInterface == null)
239-
marshalledInterface = Marshal.PtrToStructure<mono_unity_unitytls_interface>(mono_unity_get_unitytls_interface());
240-
return marshalledInterface;
238+
get
239+
{
240+
if (marshalledInterface == null)
241+
marshalledInterface = Marshal.PtrToStructure<mono_unity_unitytls_interface>(mono_unity_get_unitytls_interface());
242+
return marshalledInterface;
243+
}
241244
}
242245
}
243246
}

mcs/class/System/Mono.UnityTls/UnityTlsContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public UnityTlsContext (
5353
X509CertificateCollection clientCertificates, bool askForClientCert)
5454
: base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert)
5555
{
56-
unityTlsNative = UnityTls.GetInterface();
56+
unityTlsNative = UnityTls.NativeInterface;
5757

5858
// Need GCHandle to get a consistent pointer to this instance
5959
m_handle = GCHandle.Alloc (this);

mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal override bool ValidateCertificate (
7171
targetHost = targetHost.Substring (0, pos);
7272
}
7373

74-
var unityTlsNative = UnityTls.GetInterface();
74+
var unityTlsNative = UnityTls.NativeInterface;
7575

7676
// convert cert to native
7777
var errorState = unityTlsNative.unitytls_errorstate_create ();

0 commit comments

Comments
 (0)