public override void Close() { Debug("Close!"); if (ssl != null) { ssl.Dispose(); ssl = null; } if (ctx != null) { ctx.Dispose(); ctx = null; } if (bio != null) { bio.Dispose(); bio = null; } if (errbio != null) { errbio.Dispose(); errbio = null; } }
static BoringSslHandle Create_internal(MonoBtlsSslCtx ctx) { var handle = mono_btls_ssl_new(ctx.Handle.DangerousGetHandle()); if (handle == IntPtr.Zero) { throw new MonoBtlsException(); } return(new BoringSslHandle(handle)); }
void InitializeConnection() { ctx = new MonoBtlsSslCtx(); #if MARTIN_DEBUG errbio = MonoBtlsBio.CreateMonoStream(Console.OpenStandardError()); ctx.SetDebugBio(errbio); #endif MonoBtlsProvider.SetupCertificateStore(ctx.CertificateStore, Settings, IsServer); if (!IsServer || AskForClientCertificate) { ctx.SetVerifyCallback(VerifyCallback, false); } if (!IsServer) { ctx.SetSelectCallback(SelectCallback); } if (IsServer && (Options.ServerCertSelectionDelegate != null || Settings.ClientCertificateSelectionCallback != null)) { ctx.SetServerNameCallback(ServerNameCallback); } ctx.SetVerifyParam(MonoBtlsProvider.GetVerifyParam(Settings, ServerName, IsServer)); TlsProtocolCode?minProtocol, maxProtocol; GetProtocolVersions(out minProtocol, out maxProtocol); if (minProtocol != null) { ctx.SetMinVersion((int)minProtocol.Value); } if (maxProtocol != null) { ctx.SetMaxVersion((int)maxProtocol.Value); } if (Settings != null && Settings.EnabledCiphers != null) { var ciphers = new short [Settings.EnabledCiphers.Length]; for (int i = 0; i < ciphers.Length; i++) { ciphers [i] = (short)Settings.EnabledCiphers [i]; } ctx.SetCiphers(ciphers, true); } if (IsServer && Settings?.ClientCertificateIssuers != null) { ctx.SetClientCertificateIssuers(Settings.ClientCertificateIssuers); } }
void InitializeConnection() { ctx = new MonoBtlsSslCtx(); #if MARTIN_DEBUG errbio = MonoBtlsBio.CreateMonoStream(Console.OpenStandardError()); ctx.SetDebugBio(errbio); #endif SetupCertificateStore(); if (!IsServer || AskForClientCertificate) { ctx.SetVerifyCallback(VerifyCallback, false); } if (!IsServer) { ctx.SetSelectCallback(SelectCallback); } var host = TargetHost; if (!string.IsNullOrEmpty(host)) { var pos = TargetHost.IndexOf(':'); if (pos > 0) { host = host.Substring(0, pos); } } ctx.SetVerifyParam(MonoBtlsProvider.GetVerifyParam(host, IsServer)); TlsProtocolCode minProtocol, maxProtocol; GetProtocolVersions(out minProtocol, out maxProtocol); ctx.SetMinVersion((int)minProtocol); ctx.SetMaxVersion((int)maxProtocol); if (Settings != null && Settings.EnabledCiphers != null) { var ciphers = new short [Settings.EnabledCiphers.Length]; for (int i = 0; i < ciphers.Length; i++) { ciphers [i] = (short)Settings.EnabledCiphers [i]; } ctx.SetCiphers(ciphers, true); } }
public MonoBtlsSsl (MonoBtlsSslCtx ctx) : base (Create_internal (ctx)) { printErrorsFunc = PrintErrorsCallback; printErrorsFuncPtr = Marshal.GetFunctionPointerForDelegate (printErrorsFunc); }
static BoringSslHandle Create_internal (MonoBtlsSslCtx ctx) { var handle = mono_btls_ssl_new (ctx.Handle.DangerousGetHandle ()); if (handle == IntPtr.Zero) throw new MonoBtlsException (); return new BoringSslHandle (handle); }
public MonoBtlsSsl(MonoBtlsSslCtx ctx) : base(Create_internal(ctx)) { printErrorsFunc = PrintErrorsCallback; printErrorsFuncPtr = Marshal.GetFunctionPointerForDelegate(printErrorsFunc); }
internal MonoBtlsX509Store (MonoBtlsSslCtx.BoringSslCtxHandle ctx) : base (Create_internal (ctx)) { }
static BoringX509StoreHandle Create_internal (MonoBtlsSslCtx.BoringSslCtxHandle ctx) { var handle = mono_btls_x509_store_from_ssl_ctx (ctx.DangerousGetHandle ()); if (handle == IntPtr.Zero) throw new MonoBtlsException (); return new BoringX509StoreHandle (handle); }