private static bool OnValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
 {
     SslSocket.CertValidationResult certValidationResult = SslSocket.IsServerCertificateValid(sender, certificate, chain, sslPolicyErrors);
     if (certValidationResult == SslSocket.CertValidationResult.FAILED_CERT_BUNDLE)
     {
         SslStream sslStream  = (SslStream)sender;
         SslSocket mSslSocket = SslSocket.s_streamValidationContexts[sslStream].m_sslSocket;
         foreach (SslCertBundle sslCertBundle in SslSocket.DownloadCertBundles(mSslSocket.m_bundleSettings.bundleDownloadConfig))
         {
             mSslSocket.m_bundleSettings.bundle = sslCertBundle;
             certValidationResult = SslSocket.IsServerCertificateValid(sender, certificate, chain, sslPolicyErrors);
             if (certValidationResult != SslSocket.CertValidationResult.OK)
             {
                 continue;
             }
             FileUtil.StoreToDrive(sslCertBundle.CertBundleBytes, SslSocket.GetBundleStoragePath(), true, true);
             break;
         }
     }
     return(certValidationResult == SslSocket.CertValidationResult.OK);
 }
예제 #2
0
 private static bool OnValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
 {
     SslSocket.CertValidationResult certValidationResult = SslSocket.IsServerCertificateValid(sender, certificate, chain, sslPolicyErrors);
     if (certValidationResult == SslSocket.CertValidationResult.FAILED_CERT_BUNDLE)
     {
         SslStream key = (SslStream)sender;
         SslSocket.SslStreamValidateContext sslStreamValidateContext = SslSocket.s_streamValidationContexts[key];
         SslSocket            sslSocket            = sslStreamValidateContext.m_sslSocket;
         UrlDownloaderConfig  bundleDownloadConfig = sslSocket.m_bundleSettings.bundleDownloadConfig;
         List <SslCertBundle> list = SslSocket.DownloadCertBundles(bundleDownloadConfig);
         foreach (SslCertBundle sslCertBundle in list)
         {
             sslSocket.m_bundleSettings.bundle = sslCertBundle;
             certValidationResult = SslSocket.IsServerCertificateValid(sender, certificate, chain, sslPolicyErrors);
             if (certValidationResult == SslSocket.CertValidationResult.OK)
             {
                 FileUtil.StoreToDrive(sslCertBundle.CertBundleBytes, SslSocket.GetBundleStoragePath(), true, true);
                 break;
             }
         }
     }
     return(certValidationResult == SslSocket.CertValidationResult.OK);
 }