"Zdalny certyfikat jest nieprawidłowy zgodnie z procedurą walidacji."korzystanie z serwera Gmail SMTP

Dostaję ten błąd:

Zdalny certyfikat jest nieprawidłowy zgodnie z procedurą walidacji.

Kiedy próbuję wysłać e-mail za pomocą serwera SMTP Gmaila w moim kodzie C#. Czy ktoś może wskazać mi właściwy kierunek rozwiązania tego problemu?

Poniżej znajduje się ślad stosu...

at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Mail.SmtpConnection.Flush()
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at BulkEmail.frmemail.mailsending(String toaddress, String fromaddress, String fromname, String subject, String pwd, String attachements, String mailmessage, String htmlmessage, Int32 i, Int32 j, String replytoaddress)
 179
Author: hims056, 2009-04-22

19 answers

Uwaga: nie używaj tego w kodzie produkcyjnym!

Jako obejście można wyłączyć weryfikację certyfikatu. Tylko kiedykolwiek zrobić to, aby uzyskać potwierdzenie, że błąd jest wyrzucany z powodu złego certyfikatu.

Wywołanie tej metody przed wywołaniem smtpclient.Send():

    [Obsolete("Do not use this in Production code!!!",true)]
    static void NEVER_EAT_POISON_Disable_CertificateValidation()
    {
        // Disabling certificate validation can expose you to a man-in-the-middle attack
        // which may allow your encrypted message to be read by an attacker
        // https://stackoverflow.com/a/14907718/740639
        ServicePointManager.ServerCertificateValidationCallback =
            delegate (
                object s,
                X509Certificate certificate,
                X509Chain chain,
                SslPolicyErrors sslPolicyErrors
            ) {
                return true;
            };
    }
 269
Author: Yury Skaletskiy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-09-26 19:31:49

Link tutaj rozwiązał mój problem.

Http://brainof-dave.blogspot.com.au/2008/08/remote-certificate-is-invalid-according.html

Wszedłem na adres URL serwisu WWW (na serwerze, na którym był problem), kliknąłem na małą ikonkę bezpieczeństwa w IE, która wywołała certyfikat. Następnie kliknąłem na kartę Szczegóły, kliknąłem przycisk Kopiuj do pliku, co pozwoliło mi wyeksportować certyfikat jako .plik cer. Gdy miałem certyfikat lokalnie, mogłem go zaimportować do certyfikat przechowuje się na serwerze zgodnie z poniższymi instrukcjami.

Uruchom nowy MMC. File -- > Add/Remove Snap-In... Kliknij Dodaj... Wybierz certyfikaty i kliknij Dodaj. Zaznacz opcję "Konto komputera". Kliknij Dalej.

Wybierz komputer klienta na następnym ekranie. Kliknij Przycisk Zakończ. Kliknij Zamknij. Kliknij OK. Teraz Zainstaluj certyfikat w magazynie certyfikatów zaufanych głównych urzędów certyfikacji. Pozwoli to wszystkim użytkownikom zaufać certyfikatowi.

 47
Author: T-Rex,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-07-26 15:56:40

Możesz poprawić kod, aby zapytać użytkownika, czy certyfikat nie jest ważny. Chcesz kontynuować? Jak poniżej:

ServicePointManager.ServerCertificateValidationCallback = 
    new RemoteCertificateValidationCallback(ValidateServerCertificate);

I dodaj taką metodę:

public static bool ValidateServerCertificate(object sender,X509Certificate certificate,X509Chain chain,SslPolicyErrors sslPolicyErrors)
{
    if (sslPolicyErrors == SslPolicyErrors.None)
        return true;
    else
    {
        if (System.Windows.Forms.MessageBox.Show("The server certificate is not valid.\nAccept?", "Certificate Validation", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            return true;
        else
            return false;
    }
}
 32
Author: LinuxLover,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-08-13 04:11:40

Trochę za późno na imprezę, ale jeśli szukasz rozwiązania takiego jak Yury ' s poniższy kod pomoże Ci zidentyfikować, czy problem jest związany z certyfikatem samo podpisu, a jeśli tak, zignoruj błąd samo podpisu. Możesz oczywiście sprawdzić inne błędy SSL, jeśli tego chcesz.

Kod, którego używamy (dzięki uprzejmości Microsoftu- http://msdn.microsoft.com/en-us/library/office/dd633677(v=exchg. 80). aspx ) jest następująca:

  private static bool CertificateValidationCallBack(
         object sender,
         System.Security.Cryptography.X509Certificates.X509Certificate certificate,
         System.Security.Cryptography.X509Certificates.X509Chain chain,
         System.Net.Security.SslPolicyErrors sslPolicyErrors)
    {
  // If the certificate is a valid, signed certificate, return true.
  if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
  {
    return true;
  }

  // If there are errors in the certificate chain, look at each error to determine the cause.
  if ((sslPolicyErrors & System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors) != 0)
  {
    if (chain != null && chain.ChainStatus != null)
    {
      foreach (System.Security.Cryptography.X509Certificates.X509ChainStatus status in chain.ChainStatus)
      {
        if ((certificate.Subject == certificate.Issuer) &&
           (status.Status == System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.UntrustedRoot))
        {
          // Self-signed certificates with an untrusted root are valid. 
          continue;
        }
        else
        {
          if (status.Status != System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
          {
            // If there are any other errors in the certificate chain, the certificate is invalid,
         // so the method returns false.
            return false;
          }
        }
      }
    }

    // When processing reaches this line, the only errors in the certificate chain are 
// untrusted root errors for self-signed certificates. These certificates are valid
// for default Exchange server installations, so return true.
    return true;
  }
  else
  {
 // In all other cases, return false.
    return false;
  }
}
 21
Author: Hooligancat,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-15 16:15:20

Miałem dokładnie ten sam problem i zorientowałem się, że domyślnie Osłona poczty od Avast Antivirus miała "Skanowanie połączenia SSL" aktywowane. Upewnij się, że Wyłącz to .

Z mojej wiedzy, Avast "otworzy" pocztę, przeskanuje ją w poszukiwaniu wirusów, a następnie podpisze przy użyciu własnego certyfikatu, aby poczta nie była już podpisywana przez certyfikat Gmaila, co powoduje ten błąd.

Rozwiązanie 1:

  • Turn wyłącz skanowanie SSL z antywirusa(lub całej Osłony poczty).

Rozwiązanie 2 (powinno być najlepszym zabezpieczeniem):

    W ten sposób można uzyskać certyfikat używany przez program antywirusowy (Avast ma możliwość jego eksportu).]}
  • zaimportuj go do klienta imap / pop / smtp przed połączeniem się z serwerem gmail.
 13
Author: tehCivilian,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-02-27 22:23:25

Czy na pewno używasz poprawnego adresu serwera SMTP?

Obie smtp.google.com oraz smtp.gmail.com działa, ale certyfikat SSL jest wydawany na drugi.

 8
Author: Pawel Lesnikowski,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-12-17 22:53:36

Uzyskaj ten sam błąd podczas wysyłania z Outlooka z powodu ssl. Próba ustawienia EnableSSL = false rozwiązała problem.

Przykład:

var smtp = new SmtpClient
                {
                    Host = "smtp.gmail.com",                   
                    Port = 587,
                    EnableSsl = false,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,                   
                    Credentials = new NetworkCredential("[email protected]", "xxxxx")
                };
 7
Author: Chitra Pannirselvam,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-05-30 22:17:38

Miałem ten sam błąd, gdy próbowałem wysłać wiadomość e-mail za pomocą SmtpClient przez serwer proxy (Usergate).

Weryfikuje certyfikat zawierający adres serwera, który nie jest równy adresowi serwera proxy, stąd błąd. Moje rozwiązanie: gdy wystąpi błąd podczas sprawdzania certyfikatu, odbierz certyfikat, wyeksportuj go i sprawdź.

public static bool RemoteServerCertificateValidationCallback(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    {
        if (sslPolicyErrors == SslPolicyErrors.None)
            return true;

        // if got an cert auth error
        if (sslPolicyErrors != SslPolicyErrors.RemoteCertificateNameMismatch) return false;
        const string sertFileName = "smpthost.cer";

        // check if cert file exists
        if (File.Exists(sertFileName))
        {
            var actualCertificate = X509Certificate.CreateFromCertFile(sertFileName);
            return certificate.Equals(actualCertificate);
        }

        // export and check if cert not exists
        using (var file = File.Create(sertFileName))
        {
            var cert = certificate.Export(X509ContentType.Cert);
            file.Write(cert, 0, cert.Length);
        }
        var createdCertificate = X509Certificate.CreateFromCertFile(sertFileName);
        return certificate.Equals(createdCertificate);
    }

Pełny kod mojej klasy nadawcy e-mail:

public class EmailSender
{
    private readonly SmtpClient _smtpServer;
    private readonly MailAddress _fromAddress;

    public EmailSender()
    {
        ServicePointManager.ServerCertificateValidationCallback = RemoteServerCertificateValidationCallback;
        _smtpServer = new SmtpClient();
    }

    public EmailSender(string smtpHost, int smtpPort, bool enableSsl, string userName, string password, string fromEmail, string fromName) : this()
    {
        _smtpServer.Host = smtpHost;
        _smtpServer.Port = smtpPort;
        _smtpServer.UseDefaultCredentials = false;
        _smtpServer.EnableSsl = enableSsl;
        _smtpServer.Credentials = new NetworkCredential(userName, password);

        _fromAddress = new MailAddress(fromEmail, fromName);
    }

    public bool Send(string address, string mailSubject, string htmlMessageBody,
        string fileName = null)
    {
        return Send(new List<MailAddress> { new MailAddress(address) }, mailSubject, htmlMessageBody, fileName);
    }

    public bool Send(List<MailAddress> addressList, string mailSubject, string htmlMessageBody,
        string fileName = null)
    {
        var mailMessage = new MailMessage();
        try
        {
            if (_fromAddress != null)
                mailMessage.From = _fromAddress;

            foreach (var addr in addressList)
                mailMessage.To.Add(addr);

            mailMessage.SubjectEncoding = Encoding.UTF8;
            mailMessage.Subject = mailSubject;

            mailMessage.Body = htmlMessageBody;
            mailMessage.BodyEncoding = Encoding.UTF8;
            mailMessage.IsBodyHtml = true;

            if ((fileName != null) && (System.IO.File.Exists(fileName)))
            {
                var attach = new Attachment(fileName, MediaTypeNames.Application.Octet);
                attach.ContentDisposition.CreationDate = System.IO.File.GetCreationTime(fileName);
                attach.ContentDisposition.ModificationDate = System.IO.File.GetLastWriteTime(fileName);
                attach.ContentDisposition.ReadDate = System.IO.File.GetLastAccessTime(fileName);
                mailMessage.Attachments.Add(attach);
            }
            _smtpServer.Send(mailMessage);
        }
        catch (Exception e)
        {
            // TODO lor error
            return false;
        }
        return true;
    }

    public static bool RemoteServerCertificateValidationCallback(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
    if (sslPolicyErrors == SslPolicyErrors.None)
        return true;

    // if got an cert auth error
    if (sslPolicyErrors != SslPolicyErrors.RemoteCertificateNameMismatch) return false;
    const string sertFileName = "smpthost.cer";

    // check if cert file exists
    if (File.Exists(sertFileName))
    {
        var actualCertificate = X509Certificate.CreateFromCertFile(sertFileName);
        return certificate.Equals(actualCertificate);
    }

    // export and check if cert not exists
    using (var file = File.Create(sertFileName))
    {
        var cert = certificate.Export(X509ContentType.Cert);
        file.Write(cert, 0, cert.Length);
    }
    var createdCertificate = X509Certificate.CreateFromCertFile(sertFileName);
    return certificate.Equals(createdCertificate);
}

}

 6
Author: Evgeny Ivanov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-07-09 06:05:19

Mój problem był na Windows 2003 Server, podczas wywoływania AuthenticateAsClient. Powyższe rozwiązania (np. obejście ServicePointManager.ServerCertificateValidationCallback) nie zadziałały.

Okazuje się, że jest to błąd w Windows 2003 i jest poprawka:

"Aplikacje korzystające z API kryptografii nie mogą weryfikować certyfikatu X. 509 w systemie Windows Server 2003"

Https://support.microsoft.com/en-us/kb/938397

Instalacja tej poprawki rozwiązała mój problem.

 6
Author: user326608,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-08-12 00:12:42

Twój folder WWW wymaga zabezpieczenia usługi sieciowej. Zwłaszcza sieć.config. Używa tego konta, aby uzyskać dostęp do rejestru certyfikatów. To zatrzyma potrzebę dodawania hack do kodu.

 4
Author: Frans,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-07-19 05:37:08

Sprawdź datę i godzinę komputera. Jeśli jest nieprawidłowy, zaktualizuj go do bieżącego czasu lub Ustaw automatycznie, aby uzyskać czas z Internetu.

Ponieważ certyfikaty są powiązane z ustalonym okresem czasu, jeśli zegar jest nieprawidłowy, prawdopodobnie wystąpią takie błędy. W tym scenariuszu, ustalając czas, problem zostanie rozwiązany.

 4
Author: AliSafari186,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-12-06 21:23:18

Mój problem nie polegał na tym, że odnosiłem się do serwera poprzez adres IP zamiast adresu URL. Kupiłem podpisany certyfikat od urzędu certyfikacji do użytku w sieci prywatnej. Adres URL podany w certyfikacie ma znaczenie podczas odwoływania się do serwera. Gdy odwołałem się do serwera za pomocą adresu URL w certyfikacie, wszystko zaczęło działać.

 3
Author: Josh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-03-06 21:05:25

Dla tych, którzy napotykają ten sam błąd podczas łączenia się z witryną lokalną z certyfikatem podpisanym samodzielnie, poniższy wpis na blogu mi pomógł.

Http://brainof-dave.blogspot.com.au/2008/08/remote-certificate-is-invalid-according.html

 2
Author: NullPointer,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-05 01:46:10

W naszym przypadku problem był spowodowany certyfikatem serwera IIS. Temat certyfikatu został ustawiony na nazwę DNS, a użytkownicy próbowali uzyskać dostęp do witryny internetowej przez adres IP, więc Walidacja certyfikatu. NET nie powiodła się. Problem zniknął, gdy użytkownicy zaczęli używać nazwy DNS.

Więc musisz zmienić adres URL dostawcy na https://CertificateSubject/xxx/xxx.application

 2
Author: Ludwo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-09 10:47:39

Jest artykuł na blogu MSDN o badaniu tego typu problemów:

Rozwiązywanie problemów ASP.NET - zdalny certyfikat jest nieprawidłowy zgodnie z walidacją procedure:
http://blogs.msdn.com/b/jpsanders/archive/2009/09/16/troubleshooting-asp-net-the-remote-certificate-is-invalid-according-to-the-validation-procedure.aspx

 2
Author: David Burg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-07-13 17:58:47

Dodanie tej linii zadziałało.

System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(RemoteServerCertificateValidationCallback);

Pełny kod to

private void sendAMail(String toAddress, String messageBody)
        {
            String msg = "Sending mail to : " + toAddress;

            MailMessage mail = new MailMessage();
            mail.To.Add(toAddress);
            mail.From = new MailAddress("[email protected]");
            mail.Subject = "Subject: Test Mail";
            mail.Body = messageBody;
            mail.IsBodyHtml = true;            

            //Added this line here
            System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(RemoteServerCertificateValidationCallback);
            SmtpClient smtp = new SmtpClient();

            smtp.Host = "myhostname.com";            
            smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "");
            smtp.EnableSsl = true;
            smtp.Port = 587;            
            smtp.Send(mail);            
        }


private bool RemoteServerCertificateValidationCallback(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
    //Console.WriteLine(certificate);
    return true;
}
 1
Author: Erdnase,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-10-08 08:54:43

To rozwiązało mój problem

smtpClient.Credentials = new NetworkCredential(sendMail.UserName, sendMail.Password);
smtpClient.EnableSsl = false;//sendMail.EnableSSL;

/ / w odniesieniu do / / Problem pojawia się tylko użyj powyższej linii, aby ustawić fałszywy SSl, aby rozwiązać błąd, gdy nazwa użytkownika i hasło zostaną wprowadzone w Ustawieniach SMTP.

 0
Author: user3584038,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-12-02 05:06:10

Oto rozwiązanie, które postanowiłem wykorzystać.

        ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            string name = certificate.Subject;

            DateTime expirationDate = DateTime.Parse(certificate.GetExpirationDateString());

            if (sslPolicyErrors == SslPolicyErrors.None || (sslPolicyErrors == SslPolicyErrors.RemoteCertificateNameMismatch && name.EndsWith(".acceptabledomain.com") && expirationDate > DateTime.Now))
            {
                return true;
            }
            return false;
        };
 0
Author: The Lazy Coder,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-08-23 21:56:21

Wiem, że jestem dość późno w tej grze, ale nie widziałem tutaj odpowiedzi wskazującej na system.dzienniki diagnostyczne dla strumienia TLS.

Zanim dokonasz jakichkolwiek zmian w kodzie, upewnij się, że rozumiesz, na czym polega problem. AuthenticationException jest jednym z tych bardzo ogólnych WYJĄTKÓW, który niewiele mówi. Aby dowiedzieć się, co dzieje się pod maską edytuj aplikację.plik konfiguracyjny dla Twojej aplikacji (lub utwórz nową) i upewnij się, że masz System.Net śledzenie źródła włączone w system.diagnostics sekcja, na przykład:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.diagnostics>
    <trace autoflush="true" />
    <sharedListeners>
      <add name="file" initializeData="c:\network.log" type="System.Diagnostics.TextWriterTraceListener" />
    </sharedListeners>
    <sources>
      <source name="System.Net" switchValue="Verbose">
        <listeners>
          <add name="file" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>

Powtórz swoją aplikację i sprawdź c:\network.plik dziennika. Powinieneś tam zobaczyć szczegółowe informacje o połączeniu TLS (SSL), na przykład:

System.Net Information: 0 : [12764] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = f44368:535f958, targetName = localhost, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [12764] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=OK).
System.Net Information: 0 : [12764] Remote certificate: [Version]
  V3

[Subject]
  CN=test
  Simple Name: test
  DNS Name: example.com

[Issuer]
  CN=Root CA
  Simple Name: Root CA
  DNS Name: Root CA

...

[Signature Algorithm]
  sha256RSA(1.2.840.113549.1.1.11)

[Public Key]
  Algorithm: RSA
  Length: 2048
  Key Blob: ....
System.Net Information: 0 : [12764] SecureChannel#38496415 - Remote certificate has errors:
System.Net Information: 0 : [12764] SecureChannel#38496415 -    Certificate name mismatch.
System.Net Information: 0 : [12764] SecureChannel#38496415 - Remote certificate was verified as invalid by the user.
System.Net Error: 0 : [12764] Exception in AppDomain#10923418::UnhandledExceptionHandler - The remote certificate is invalid according to the validation procedure..

Wiedząc, co powoduje problem, powinieneś być w stanie go rozwiązać lub przynajmniej zawęzić wyszukiwania Google.

 0
Author: lowleveldesign,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-10-05 15:27:28