Esempio n. 1
0
        public void ClientEncryption4Queue()
        {
            var    kv       = new KeyVaultTester("624c0e2f-6122-4b26-a229-06431f82e6b3", "C35CBFF9FA6C51E51E1DE97B6D1E246F27661301", "https://kvsignalrdeva.vault.azure.net");
            var    name     = "AzSignalR-Storage-ClientEncryptionKey";
            var    rsaValue = kv.GetSecretAsync(name).Result;
            string kid      = "signalrkeyid";

            StorageRunnerContext.RunOnQueue(storage,
                                            "jwtestqueuea" + Guid.NewGuid().ToString().Substring(0, 8),
                                            (cloudQueue) =>
            {
                var csp1 = new RSACryptoServiceProvider();
                csp1.FromXmlString(rsaValue);
                var rsa1 = new RsaKey(kid, csp1);
                QueueEncryptionPolicy policy = new QueueEncryptionPolicy(rsa1, null);
                QueueRequestOptions options  = new QueueRequestOptions()
                {
                    EncryptionPolicy = policy
                };
                cloudQueue.AddMessage(new CloudQueueMessage("messageContentABC"), null, null, options, null);

                // Retrieve message
                var csp2 = new RSACryptoServiceProvider();
                csp2.FromXmlString(rsaValue);
                var rsa2 = new RsaKey(kid, csp2);
                QueueEncryptionPolicy policy2 = new QueueEncryptionPolicy(rsa2, null);
                QueueRequestOptions options2  = new QueueRequestOptions()
                {
                    EncryptionPolicy = policy2
                };
                CloudQueueMessage retrMessage = cloudQueue.GetMessage(null, options2, null);
                Console.WriteLine(retrMessage.AsString);
            });
        }
Esempio n. 2
0
        public void QueueMessageVisibleTest()
        {
            StorageRunnerContext.RunOnQueue(storage,
                                            "jwtestqueue" + Guid.NewGuid().ToString().Substring(0, 8),
                                            (queue) =>
            {
                var msg = new CloudQueueMessage("any string");
                queue.AddMessage(msg);

                var gm = queue.GetMessage(TimeSpan.FromMinutes(3));
                queue.UpdateMessage(gm, TimeSpan.FromSeconds(5), MessageUpdateFields.Visibility);
                queue.UpdateMessage(gm, TimeSpan.FromMinutes(5), MessageUpdateFields.Visibility);
                queue.UpdateMessage(gm, TimeSpan.FromSeconds(5), MessageUpdateFields.Visibility);
            });
        }