public SafeDeleteSslContext(SafeFreeSslCredentials credential, SslAuthenticationOptions sslAuthenticationOptions) : base(credential) { Debug.Assert((null != credential) && !credential.IsInvalid, "Invalid credential used in SafeDeleteSslContext"); try { unsafe { _readCallback = ReadFromConnection; _writeCallback = WriteToConnection; } _sslContext = CreateSslContext(credential, sslAuthenticationOptions.IsServer); int osStatus = Interop.AppleCrypto.SslSetIoCallbacks( _sslContext, _readCallback, _writeCallback); if (osStatus != 0) { throw Interop.AppleCrypto.CreateExceptionForOSStatus(osStatus); } } catch (Exception ex) { Debug.Write("Exception Caught. - " + ex); Dispose(); throw; } }
protected override void Dispose(bool disposing) { if (disposing) { if (null != _sslContext) { _sslContext.Dispose(); _sslContext = null; } _toConnection = null; _fromConnection = null; _writeCallback = null; _readCallback = null; } base.Dispose(disposing); }
public SafeDeleteSslContext(SafeFreeSslCredentials credential, SslAuthenticationOptions sslAuthenticationOptions) : base(credential) { Debug.Assert((null != credential) && !credential.IsInvalid, "Invalid credential used in SafeDeleteSslContext"); try { unsafe { _readCallback = ReadFromConnection; _writeCallback = WriteToConnection; } _sslContext = CreateSslContext(credential, sslAuthenticationOptions.IsServer); int osStatus = Interop.AppleCrypto.SslSetIoCallbacks( _sslContext, _readCallback, _writeCallback); if (osStatus != 0) { throw Interop.AppleCrypto.CreateExceptionForOSStatus(osStatus); } if (sslAuthenticationOptions.ApplicationProtocols != null) { // On OSX coretls supports only client side. For server, we will silently ignore the option. if (!sslAuthenticationOptions.IsServer) { Interop.AppleCrypto.SslCtxSetAlpnProtos(_sslContext, sslAuthenticationOptions.ApplicationProtocols); } } } catch (Exception ex) { Debug.Write("Exception Caught. - " + ex); Dispose(); throw; } }