MemoryHandle memHandle = input.Retain(pin: true);
try
{
- PAL_TlsIo status = Interop.AppleCrypto.SslWrite(sslHandle, (byte*)memHandle.Pointer, input.Length, out int written);
+ PAL_TlsIo status;
+
+ lock (sslHandle)
+ {
+ status = Interop.AppleCrypto.SslWrite(
+ sslHandle,
+ (byte*)memHandle.Pointer,
+ input.Length,
+ out int written);
+ }
if (status < 0)
{
fixed (byte* offsetInput = &buffer[offset])
{
int written;
- PAL_TlsIo status = Interop.AppleCrypto.SslRead(sslHandle, offsetInput, count, out written);
+ PAL_TlsIo status;
+
+ lock (sslHandle)
+ {
+ status = Interop.AppleCrypto.SslRead(sslHandle, offsetInput, count, out written);
+ }
if (status < 0)
{
sslContext.Write(inputBuffer.token, inputBuffer.offset, inputBuffer.size);
}
- SecurityStatusPal status = PerformHandshake(sslContext.SslContext);
+ SafeSslHandle sslHandle = sslContext.SslContext;
+ SecurityStatusPal status;
+
+ lock (sslHandle)
+ {
+ status = PerformHandshake(sslHandle);
+ }
byte[] output = sslContext.ReadPendingWrites();
outputBuffer.offset = 0;
SafeDeleteContext securityContext)
{
SafeDeleteSslContext sslContext = ((SafeDeleteSslContext)securityContext);
- int osStatus = Interop.AppleCrypto.SslShutdown(sslContext.SslContext);
+ SafeSslHandle sslHandle = sslContext.SslContext;
+ int osStatus;
+
+ lock (sslHandle)
+ {
+ osStatus = Interop.AppleCrypto.SslShutdown(sslHandle);
+ }
if (osStatus == 0)
{