public async void RefreshTrustListAsync()
        {
            DSC_TL trustList = await _restService.RefreshTrustListAsync();

            if (trustList != null && trustList.DscTrustList != null && trustList.DscTrustList.Count > 0)
            {
                TrustList = trustList;
                await File.WriteAllTextAsync(FileName, DSC_TLSerialize.ToJson(trustList));
            }
        }
 private void LoadCertificates()
 {
     if (TrustList == null && File.Exists(FileName))
     {
         DSC_TL trustList = DSC_TL.FromJson(File.ReadAllText(FileName));
         TrustList = trustList;
     }
     // If trustlist is not set or it´s older than 24 hours refresh it
     if (TrustList == null || (TrustList.Iat + 86400) < GetSecondsFromEpoc())
     {
         RefreshTrustListAsync();
     }
 }
Example #3
0
        public async Task <DSC_TL> RefreshTrustListAsync()
        {
            DSC_TL trustList = new DSC_TL();
            Uri    uri       = new Uri(string.Format(Constants.RestUrl, "dsctl"));

            try
            {
                HttpResponseMessage response = await client.GetAsync(uri);

                if (response.IsSuccessStatusCode)
                {
                    string content = await response.Content.ReadAsStringAsync();

                    trustList = DSC_TL.FromJson(content);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"\tERROR {0}", ex.Message);
            }

            return(trustList);
        }