예제 #1
0
        private async Task EnsureDeleteOldCertificates()
        {
            UserCertificateStore certificateStore = CertificateStores.GetUserStoreByName(StandardCertificateStoreNames.Personal);
            var certificateFinder = await CertificateStores.FindAllAsync(new CertificateQuery()
            {
                IncludeDuplicates = true, IncludeExpiredCertificates = true
            });

            foreach (Certificate oldCertificate in certificateFinder)
            {
                if (oldCertificate.Issuer.StartsWith("Azure IoT Edison Intermediate"))
                {
                    try
                    {
                        await certificateStore.RequestDeleteAsync(oldCertificate);
                    }
                    catch (Exception e)
                    {
                        DebugHelper.LogWarning($"An old certificate could not be deleted: {e.Message}");
                    }
                }
            }
        }