Exemple #1
0
        ///<inheritdoc/>
        protected override async Task <string> SafeCreateNewToken(string iotHub, int suggestedTimeToLive)
        {
            DateTime startTime = DateTime.UtcNow;
            string   audience  = SasTokenBuilder.BuildAudience(iotHub, DeviceId, ModuleId);
            string   expiresOn = SasTokenBuilder.BuildExpiresOn(startTime, TimeSpan.FromSeconds(suggestedTimeToLive));
            string   data      = string.Join("\n", new string[] { audience, expiresOn });
            string   signature = await _signatureProvider.SignAsync(ModuleId, _generationId, data).ConfigureAwait(false);

            return(SasTokenBuilder.BuildSasToken(audience, signature, expiresOn));
        }