//private static bool ValidateRemoteCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) //{ // return true; // //var certificateToValidate = new X509Certificate2(certificate); // //chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; // //chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot; // //chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority; // We have an untrusted root ca certificate // //chain.ChainPolicy.VerificationTime = DateTime.Now; // //chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 0, 0); // //chain.ChainPolicy.ExtraStore.Add(_clientCert); // //bool isChainValid = chain.Build(certificateToValidate); // //if (!isChainValid) // //{ // // string[] errors = chain.ChainStatus // // .Select(x => $"{x.StatusInformation.Trim()} ({x.Status})") // // .ToArray(); // // string certificateErrorsString = "Unknown errors."; // // if (errors.Length > 0) // // { // // certificateErrorsString = string.Join(", ", errors); // // } // // throw new Exception("Trust chain did not complete to the known authority anchor. Errors: " + certificateErrorsString); // //} // //// Check if chain contains our root ca certificate // //var valid = chain.ChainElements // // .Cast<X509ChainElement>() // // .Any(x => x.Certificate.Thumbprint == _clientCert.Thumbprint); // //return valid; //} private static void HotelPmsClient_Disconnect() { Logger.Warn("A connect with the hotel's PMS had lost. Try to reconnect"); var mail = new Smtpmail.SendingMail(Config.SendTo, "A connect with the hotel's PMS had lost.") { Subj = "Connectin with PMS was dropped" }; mail.SendMail(); Connect2Pms(); }
private static void _clientMqtt_ConnectionClosed(object sender, EventArgs e) { var mail = new Smtpmail.SendingMail(Config.SendTo, "A connect with the MQTT's broker has lost.") { Subj = "Connectin with MQTT was dropped" }; mail.SendMail(); Logger.Warn("--------MQTT Connection closed-----------"); _clientMqtt.Unsubscribe(new string[] { Config.SubscribeTopic }); _clientMqtt = null; Connect2Mqtt(); }