Skip to content

Commit e618bee

Browse files
authored
Merge pull request #872 from Unity-Technologies/unity-master-unitytls-rawhandle-interface-workaround
Workaround for crash on Android when calling unitytls_tlsctx_create_server
2 parents 3633b8e + 2d68de1 commit e618bee

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ public class unitytls_interface_struct
231231
public delegate unitytls_x509verify_result unitytls_x509verify_explicit_ca_t(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState);
232232
public unitytls_x509verify_explicit_ca_t unitytls_x509verify_explicit_ca;
233233

234+
// Note that we take UInt64 here instead of handles!
235+
// This a workaround for an android specific crash, caused by a bug in Mono's implementation of native calls through the arm ABI.
234236
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
235-
public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState);
237+
public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, UInt64 certChain, UInt64 leafCertificateKey, unitytls_errorstate* errorState);
236238
public unitytls_tlsctx_create_server_t unitytls_tlsctx_create_server;
237239
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
238240
public delegate unitytls_tlsctx* unitytls_tlsctx_create_client_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public UnityTlsContext (
8080
var serverKeyRef = UnityTls.NativeInterface.unitytls_key_get_ref (serverPrivateKey, &errorState);
8181
Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate");
8282

83-
tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState);
83+
tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef.handle, serverKeyRef.handle, &errorState);
8484

8585
if (askForClientCert) {
8686
UnityTls.unitytls_x509list* clientAuthCAList = null;

0 commit comments

Comments
 (0)