internal static X509Certificate2?DownloadCertificate(string uri, TimeSpan downloadTimeout)
        {
            byte[]? data = DownloadAsset(uri, downloadTimeout);

            if (data == null || data.Length == 0)
            {
                return(null);
            }

            try
            {
                X509Certificate2 certificate = new X509Certificate2(data);
                certificate.ThrowIfInvalid();
                return(certificate);
            }
            catch (CryptographicException)
            {
                if (OpenSslX509ChainEventSource.Log.IsEnabled())
                {
                    OpenSslX509ChainEventSource.Log.InvalidDownloadedCertificate();
                }

                return(null);
            }
        }
Example #2
0
        internal static X509Certificate2?DownloadCertificate(string uri, TimeSpan downloadTimeout)
        {
            byte[]? data = DownloadAsset(uri, downloadTimeout);

            if (data == null || data.Length == 0)
            {
                return(null);
            }

            try
            {
                X509Certificate2 certificate = new X509Certificate2(data);
                certificate.ThrowIfInvalid();
                return(certificate);
            }
            catch (CryptographicException)
            {
                return(null);
            }
        }