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); } }