static void Main(string[] args) { changeConsoleUi(); if (!isAdministrator()) { var message = "Certificate not created: the certificate can only be set under administrator permissions"; Log.Me.Error(message); throw new Exception(message); } TLSConfig.Address = args.Length == 0 ? "localhost" : args[0]; Log.TryLogOnException(() => TLSConfig.Generate()); ServiceUser.GrantLogAccess(); }
private void ValidateConfig(TLSConfig config) { if (string.IsNullOrWhiteSpace(config.peerCertFilePath) || string.IsNullOrWhiteSpace(Path.GetFullPath(config.peerCertFilePath))) { throw new Exception("Invalid Trusted Certificate File Path"); } if (string.IsNullOrWhiteSpace(config.localCertFilePath) || string.IsNullOrWhiteSpace(Path.GetFullPath(config.localCertFilePath))) { throw new Exception("Invalid Certificate File Path"); } if (string.IsNullOrWhiteSpace(config.privateKeyFilePath) || string.IsNullOrWhiteSpace(Path.GetFullPath(config.privateKeyFilePath))) { throw new Exception("Invalid Private Key File Path"); } if (!(config.allowTLSv10 || config.allowTLSv11 || config.allowTLSv12)) { throw new Exception("At least one TLS version must be selected"); } }
public void Start(Boolean ssl = true) { var addresses = Dns.GetHostAddresses(Options.BindAddress); server = new WebSocketServer(addresses[0], options.BindPort, ssl); TLSConfig.Address = Options.BindAddress; if (ssl) { server.SslConfiguration.ServerCertificate = TLSConfig.Get(); server.SslConfiguration.CheckCertificateRevocation = false; server.SslConfiguration.ClientCertificateRequired = false; server.SslConfiguration.ClientCertificateValidationCallback = TLSConfig.ClientValidate; server.KeepClean = false; } server.Log.File = Log.GetLogFilePath(); server.AddWebSocketService("/mpos", () => new BifrostBehavior(this)); server.Start(); }
/// <summary> /// Initializes a new instance of the <see /// cref="ModernHttpClient.NativeMessageHandler"/> class. /// </summary> /// <param name="throwOnCaptiveNetwork">If set to <c>true</c> throw on /// captive network (ie: a captive network is usually a wifi network /// where an authentication html form is shown instead of the real /// content).</param> /// <param name="sSLConfig">To enable TLS Mutual Authentication</param> /// <param name="cookieHandler">Enable native cookie handling. /// </param> public NativeMessageHandler(bool throwOnCaptiveNetwork, TLSConfig tLSConfig, NativeCookieHandler cookieHandler = null, IWebProxy proxy = null) : base() { }