コード例 #1
0
        private static async Task <Response> GetResponse(string policyKeyId)
        {
            var response = new Response();

            if (!string.IsNullOrEmpty(policyKeyId))
            {
                var client = new TrustFrameworkClient(
                    clientId: Environment.GetEnvironmentVariable("B2C_CLIENT_ID"),
                    clientSecret: Environment.GetEnvironmentVariable("B2C_CLIENT_SECRET"),
                    tenantId: Environment.GetEnvironmentVariable("B2C_TENANT_ID"));

                DateTimeOffset expiration = await client.GetCertificateExpiration(policyKeyId);

                response.Value             = expiration;
                response.HoursToExpiration = (int)expiration.Subtract(DateTimeOffset.UtcNow).TotalHours;
                response.Expired           = response.HoursToExpiration < HoursBeforeCertificateConsideredExpired;
            }
            else
            {
                response.Expired           = true;
                response.HoursToExpiration = -1;
                response.Value             = null;
            }

            return(response);
        }
コード例 #2
0
        static async Task Main(string[] args)
        {
            var client     = new TrustFrameworkClient(clientId, clientSecret, tenantId);
            var expiration = await client.GetCertificateExpiration(policyKeyId);

            var dateTime = expiration.DateTime;

            // print out the date/time of the certificate
            Console.WriteLine($"Expiration Date: {dateTime.ToLongDateString()} {dateTime.ToLongTimeString()}");
        }